View source: R/percLikertPlot.R
percLikertPlot | R Documentation |
Plots the percentage of answers of likert scale answer options. Alternative could be likert::likert()
percLikertPlot(dat, itemLabels = NULL, refItem = dat[, 1])
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. |
Returns a plot and the percentage values on console
Axel Zinkernagel zinkernagel@uni-wuppertal.de
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.