ggvio: Violin plot wrapper for categorical covariates

View source: R/fn_gg.R

ggvioR Documentation

Violin plot wrapper for categorical covariates

Description

Create violin plots for a chosen variable by all discrete covariates in a dataset. Numeric variables will be dropped, except the chosen variable to plot.

Usage

ggvio(d, var, cats, alpha = 0.1, show = TRUE, nsub = TRUE, ...)

Arguments

d

⁠<dfr>⁠ A data frame.

var

⁠<var>⁠ A variable to plot as unquoted name.

cats

⁠<var>⁠ Optional. Categorical variables to plot as a vector of unquoted names.

alpha

⁠<num>⁠ Alpha value for ggplot2::geom_jitter.

show

⁠<lgl>⁠ TRUE to show data using ggplot2::geom_jitter.

nsub

⁠<lgl>⁠ Show number of observations.

...

Additional arguments for ggplot2::geom_violin.

Value

A ggplot object.

Examples

d = mtcars |> mutate(across(c(am,carb,cyl,gear,vs),factor))
d |> ggvio(mpg)
d |> ggvio(mpg,alpha=0.5)
d |> ggvio(mpg,show=FALSE)
d |> ggvio(mpg,nsub=FALSE)
d |> ggvio(mpg,c(cyl,vs))

edar documentation built on Nov. 15, 2026, 1:07 a.m.