View source: R/boxplot_redef_function.R
mean_sd | R Documentation |
This function re-defines the hinges of a boxplot to equal the mean +/- one standard deviation of the data
and the whiskers to be the range of the data (min and max).
See also mean.2sd for box defined by 1.96 std. dev.
mean_sd(x)
x |
a vector of numeric data |
a <- rnorm(50, 0, 1)
b <- rnorm(120, 0.5, 1.5)
c <- rnorm(70, 1, 0.5)
d <- rnorm(15, 0,1)
group <- factor(rep(1:4, c(50, 120, 70, 15)))
mydata <- data.frame(c(a,b,c,d), group)
names(mydata) <- c("value", "group")
p1 <- ggplot(aes(y = value, x = factor(group)), data = mydata)
p1 <- (p1 + stat_summary(fun.data = mean.sd, geom = "boxplot")
+ geom_jitter(position=position_jitter(width=.2), size=1.5)
+ ggtitle("Boxplot con media, 1 Std. Dev., valore min. e max.") + xlab("Gruppi") + ylab("Valori"))
p1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.