matrix_likert | R Documentation |
The function produces a visually appealing diverging stacked bar chart, allowing for easy interpretation of the distribution of responses to a specific Likert-scale question. The function supports customization of labels, colors, and weights, providing flexibility in data representation.
matrix_likert(
dataset,
question,
labels = NULL,
colors = NULL,
weights = NULL,
na.rm = TRUE
)
dataset |
The input dataframe (or tibble) of survey questions |
question |
The columns that contain each of the response options for a question, can be selected by using tidyselect semanatics or providing a vector of column names or numbers |
labels |
Optional vector specifying labels for each response category. If not provided, it extracts labels from the original dataset. |
colors |
Optional vector specifying colors for each response category. Default colors are provided for 3 and 5 categories. If not specified, the function expects a vector of color codes. |
weights |
Optional variable containing survey weights. If provided, frequencies and counts will be weighted accordingly. |
na.rm |
Logical indicating whether to remove NA values from |
A ggplot2 object representing a diverging stacked bar chart displaying the distribution of Likert-scale responses. The chart is customized based on the provided or extracted labels and colors.
Other matrix questions:
matrix_freq()
,
matrix_mean()
,
matrix_table()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.