Description Usage Arguments Details Value References See Also Examples
View source: R/gg_boxplot_plus.R
A boxplot (in the style of Tukey) with additional components: mean and its confidence intervals as well as jittered points.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | gg_boxplot_plus(
formula,
data = NULL,
cld = NULL,
xlab = NULL,
ylab = NULL,
legend_title = NULL,
sort_groups = c("no", "yes", "ascending", "descending", TRUE, FALSE),
sort_fun = median,
add_points = TRUE,
notch = FALSE,
varwidth = FALSE,
add_mean_ci = TRUE,
conf_level = 0.95,
ci_boot_reps = 999,
cld_color = "black",
cld_y_adj = 0,
cld_y_mult = 0.06,
ci_x_adj = -0.3,
points_x_adj = 0.3,
gr_sep = "|",
x_rotate = c(0, 30, 60, 90),
...
)
|
formula |
a formula with two variable names to analyze. First one is numeric, second one is a factor, e.g. |
data |
a data frame with data. |
cld |
a data frame with cld results (object of class |
xlab |
(character) |
ylab |
(character) |
legend_title |
(character) |
sort_groups |
( |
sort_fun |
A function that calculates one numeric statistic
(name without quotes). May be |
add_points |
( |
notch |
( |
varwidth |
(logical) |
add_mean_ci |
( |
conf_level |
(numeric) Confidence level for confidence interval. Number from 0 to 1. Default is 0.95. |
ci_boot_reps |
(numeric) Number of bootstrap repetitions for mean confidence interval calculation. |
cld_color |
(character) |
cld_y_adj |
(numeric) |
cld_y_mult |
(numeric) |
ci_x_adj |
(numeric) |
points_x_adj |
(numeric) |
gr_sep |
(character) |
x_rotate |
(character|numeric) |
... |
arguments to |
The boxplot compactly displays the distribution of a continuous numeric variable. It visualises five summary statistics (including the first quartile, the median, and the third quartile) as well as all "outlying" points individually.
The plot is based on ggplot2, thus ggplot2
elements can be
added to modify the plot.
A ggplot2 plot object.
Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P. A. (1983) Graphical Methods for Data Analysis. Wadsworth & Brooks/Cole.
https://en.wikipedia.org/wiki/Box_plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | library(biostat)
# Example 1a
gg_boxplot_plus(~decrease, OrchardSprays)
# Example 1b
gg_boxplot_plus(decrease ~ treatment, OrchardSprays)
gg_boxplot_plus(~ decrease | treatment, OrchardSprays)
# Example 2
gg_boxplot_plus(decrease ~ treatment, OrchardSprays,
sort_groups = "descending"
)
# Example 3a
res <- posthoc_anova(weight ~ Diet, data = ChickWeight)
cld_result <- make_cld(res)
gg_boxplot_plus(weight ~ Diet,
data = ChickWeight,
cld = cld_result
)
# Example 3b
gg_boxplot_plus(weight ~ Diet,
data = ChickWeight,
cld = cld_result,
sort_groups = "descending",
sort_fun = mean
)
# Example 3c: do simple transformations
gg_boxplot_plus(log(weight) ~ Diet,
data = ChickWeight,
sort_groups = "descending",
sort_fun = mean
)
# Example 3d: facetting
gg_boxplot_plus(weight ~ as.factor(Time), data = ChickWeight) +
facet_wrap("Diet")
# Example 4
res2 <- posthoc_anova(decrease ~ treatment, data = OrchardSprays)
cld_result2 <- make_cld(res2)
gg_boxplot_plus(decrease ~ treatment,
data = OrchardSprays,
cld = cld_result2,
sort_groups = "descending",
sort_fun = mean
)
gg_boxplot_plus(decrease ~ treatment,
data = OrchardSprays,
cld = cld_result2,
sort_groups = "ascending",
sort_fun = IQR
)
# Example 5
gg_boxplot_plus(~ weight | Diet + Chick, data = ChickWeight)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.