itemplot: itemplot

View source: R/itemplot.R

itemplotR Documentation

itemplot

Description

Function to draw distribution of Likert scaled item with relative frequencies, mean, 1., 2. and 3. quartile.

Usage

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
)

Arguments

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

Examples

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"))

ingmarboeschen/graphing documentation built on Jan. 14, 2025, 7:32 a.m.