percLikertPlot: Plots the percentage of answers of likert scale answer...

View source: R/percLikertPlot.R

percLikertPlotR Documentation

Plots the percentage of answers of likert scale answer options. Alternative could be likert::likert()

Description

Plots the percentage of answers of likert scale answer options. Alternative could be likert::likert()

Usage

percLikertPlot(dat, itemLabels = NULL, refItem = dat[, 1])

Arguments

dat

A dataframe with items in columns.

itemLabels

Labels of the anwer options. If empty, no legend is added.

refItem

Name of the column of the Item which should be used for reference. It is used for number of categories and should contain all possible values. Default is the first item.

Value

Returns a plot and the percentage values on console

Author(s)

Axel Zinkernagel zinkernagel@uni-wuppertal.de

Examples

## Not run: 
itemNames <- c("Item1", "Item2", "Item3")
df <- matrix(c(4, 2, 4,
            1, 0, 2,
            4, 4, 4,
            3, 3, 2,
            3, 3, 2,
            0, 4, 2,
            2, 4, 2),
          ncol = 3, byrow = TRUE)
df <- as.data.frame(df)
names(df) <- itemNames
# itemLabels <- attr(attr(df[,"Item1"], "value.labels"), "names")
itemLabels <- c("Strongly disagree", "Disagree", "Neither agree nor disagree", "Agree", "Strongly agree")

percLikertPlot(df)
percLikertPlot(df, itemLabels = itemLabels)
percLikertPlot(df, refItem = df[,"Item3"], itemLabels = itemLabels) # leads to an error

## End(Not run)

axzinker/axBoost documentation built on July 4, 2024, 9:14 p.m.