This is a general function, it can be used in any proper analysis.
a data.frame
.
a group variable name/index.
a distribution variable name/index.
a function to summarize, default is stats::median, can also be mean.
if TRUE
, reorder the groups by summary measure computed
by argument fun
.
alpha for points, range from 0 to 1.
a string 'label' (default) for labeling with sample size, or 'norm' to show just group name, or a named vector to set facet labels.
angle for facet labels, default is 0
.
position for facet labels, default is 'top', can also be 'bottom'.
size of point.
size of segment.
color of segment.
title for x axis.
title for y axis.
number of row.
background color for plot panel.
a ggplot
object.
# \donttest{
set.seed(1234)
data <- data.frame(
yval = rnorm(120),
gr = c(rep("A", 50), rep("B", 40), rep("C", 30))
)
p <- show_group_distribution(data,
gvar = 2, dvar = 1,
g_label = "norm",
background_color = "grey"
)
p
p2 <- show_group_distribution(data,
gvar = "gr", dvar = "yval",
g_position = "bottom",
order_by_fun = TRUE,
alpha = 0.3
)
p2
# Set custom group names
p3 <- show_group_distribution(data,
gvar = 2, dvar = 1,
g_label = c("A" = "X", "B" = "Y", "C" = "Z")
)
p3
# }