Created
December 2, 2016 12:48
-
-
Save timcdlucas/1fb6c4e4ebc4de0ac42c6458bfa00572 to your computer and use it in GitHub Desktop.
violin and CIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1 <- data.frame(y = rnorm(100), x = letters[1:2]) | |
df2 <- data.frame(aggregate(. ~ x, df1, mean), | |
upperCI = aggregate(. ~ x, df1, function(x) quantile(x, 0.025))[, 2], | |
lowerCI = aggregate(. ~ x, df1, function(x) quantile(x, 0.975))[, 2]) | |
ggplot() + | |
geom_violin(data = df1, aes(x = x, y = y)) + | |
geom_errorbar(data = df2, aes(x = x, ymax = upperCI, ymin = lowerCI), width = 0.5) + | |
geom_point(data = df2, aes(x, y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment