powered by
Create box plots for a chosen variable by all discrete covariates in a dataset. Numeric variables will be dropped, except the chosen variable to plot.
ggbox(d, var, cats, alpha = 0.1, show = TRUE, nsub = TRUE, ...)
A ggplot object.
<dfr> A data frame.
<dfr>
<var> A variable to plot as unquoted name.
<var>
<var> Optional. Categorical variables to plot as a vector of unquoted names.
<num> Alpha value for ggplot2::geom_jitter.
<num>
<lgl> TRUE to show data using ggplot2::geom_jitter.
<lgl>
TRUE
<lgl> Show number of observations.
Additional arguments for ggplot2::geom_boxplot.
d = mtcars |> mutate(across(c(am,carb,cyl,gear,vs),factor)) d |> ggbox(mpg) d |> ggbox(mpg,alpha=0.5) d |> ggbox(mpg,show=FALSE) d |> ggbox(mpg,nsub=FALSE) d |> ggbox(mpg,c(cyl,vs))
Run the code above in your browser using DataLab