This function provides a user-friendly way to visualize densities of a numeric variable across levels of a categorical variable.

visualize_densities(
  cat_var,
  num_var,
  cat_var_name = "Categorical Variable",
  num_var_name = "Numeric Variable",
  level_labels = NULL,
  xlab = NULL,
  main = NULL,
  colors = NULL
)

Arguments

cat_var

The categorical variable.

num_var

The numerical variable.

cat_var_name

The desired name/label of the categorical variable. If no name is provided, it will default to "Categorical Variable."

num_var_name

The desired name/label of the numeric variable. If no name is provided, it will default to "Numeric Variable."

level_labels

The desired labels of the levels of the categorical variable. If no labels are provided, the labels will be the values found in the data.

xlab

The desired label of the x-axis, a character string.

main

The desired title, a character string.

colors

The desired colors for the densities, a character vector.

Value

A density plot of the inputted variables.