matrix_likert {surveyexplorer}R Documentation

Plot Likert-scale responses using ggplot2.

Description

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.

Usage

matrix_likert(
  dataset,
  question,
  labels = NULL,
  colors = NULL,
  weights = NULL,
  na.rm = TRUE
)

Arguments

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 question before analysis.

Value

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.

See Also

Other matrix questions: matrix_freq(), matrix_mean(), matrix_table()


[Package surveyexplorer version 0.1.0 Index]