mean_plot | R Documentation |
Plots group means with error bars. Error bars can be standard deviations, standard errors, or confidence intervals. Optionally, plots can be based on robust statistics.
mean_plot( data, y, x, by, pointsize = 2, dodge = 0.2, lines = TRUE, width = 0.2, error_type = c("se", "sd", "ci"), percent = 0.95, robust = FALSE )
data |
a data frame. |
y |
a numeric response variable. |
x |
a categorical explanatory variable. |
by |
a second categorical explanatory variable (optional). |
pointsize |
numeric. Point size (default = 2). |
dodge |
numeric. If a |
lines |
logical. If |
width |
numeric. Width of the error bars (default = 0.2). Set to 0 to produce pointranges instead of error bars. |
error_type |
character. Error bars represents either standard deviations
|
percent |
numeric. if |
robust |
logical. If |
Robust statistics are based on deciles, the nine values that divide the response variable into 10 equal groups (where each group contains roughly the same fraction of cases). The robust mean is the mean of these nine decile values. The robust standard deviation is the sample standard deviation of the nine decile values. The standard error and confidence interval are calculated in the normal way, but use the robust mean and standard deviation in their calculations. See Abu-Shawiesh et al (2022).
a ggplot2
graph.
Ahmed Abu-Shawiesh, M., Sinsomboonthong, J., & Kibria, B. (2022). A modified robust confidence interval for the population mean of distributrion baed on deciles. Statistics in Transition, vol. 23 (1). pdf
mean_plot(cars74, mpg, cyl) mean_plot(cars74, mpg, cyl, am) mean_plot(cars74, mpg, cyl, am, error_type = "ci", percent = 0.9, width = 0, lines = FALSE, robust = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.