itemplot | R Documentation |
Function to draw distribution of Likert scaled item with relative frequencies, mean, 1., 2. and 3. quartile.
itemplot(
x,
col = "lightblue",
col2 = c("red", "blue"),
labels = c(levels(x)[1], levels(x)[length(levels(x))]),
main = "",
dec = 1,
legend = TRUE,
decmean = 2,
quant.type = 4,
pt.cex = 1.2,
values = round(c(mean(a, na.rm = T), median(a, na.rm = T), quantile(a, 0.25, type =
quant.type, na.rm = T), quantile(a, 0.75, type = quant.type, na.rm = T), length(a)),
2),
legendtext = c(as.expression(bquote("Mean" == .(round(mean(as.numeric(x), na.rm = T),
decmean)))), as.expression(bquote("Median" == .(median(as.numeric(x), na.rm = T)))),
as.expression(bquote("1. Quartile" == .(quantile(as.numeric(x), 0.25, type =
quant.type, na.rm = T)))), as.expression(bquote("3. Quartile" ==
.(quantile(as.numeric(x), 0.75, type = quant.type, na.rm = T)))),
as.expression(bquote("N "[included] == .(sum(table(x))))),
as.expression(bquote("N "[missing] == .(sum(is.na(x)))))),
cex = 1
)
x |
a likert scaled factor variable |
col |
color of bars |
col2 |
color for mean and median |
labels |
a vector of length 2 with low and high level labels |
main |
title |
dec |
decimal digits for percentage on bars |
legend |
Logical. If TRUE draws legend |
decmean |
decimal digits for mean diplayed in legend |
quant.type |
quantile type |
pt.cex |
median and mean point size |
values |
legend values |
legendtext |
legends text |
cex |
text size |
x<-factor(sample(letters[1:6],100,T))
itemplot(x,main="itemplot()",labels=c("I fully\n disagree","I fully\n agree"),legend=F)
itemplot(x,main="itemplot()",labels=c("I fully\n disagree","I fully\n agree"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.