Learn R Programming

kutils (version 1.0)

likert: Percentage tables for Likert Scale variables

Description

Creates a table with columns for allowed values and rows for variables.

Usage

likert(vlist, data, labels, outdir, fn, rows = TRUE)

Arguments

vlist

A vector of variable names

data

A data frame

labels

A vector of values to replace existing levels

outdir

Output directory

fn

file name for output: not used yet. See example for one way to save result.

rows

Currently unused indicator for whether output should be transposed.

Value

character vector

Examples

Run this code
# NOT RUN {
vvector <- c("Strongly Disagree", "Disagree", "Neutral",
              "Agree", "Strongly Agree")
set.seed(2342234)
N <- 142
scales <-
    data.frame(Vegas = factor(sample(1:5, N, replace = TRUE), labels = vvector),
               NewYork = factor(sample(1:5, N, replace = TRUE), labels = vvector),
               Paris = factor(sample(1:5, N, replace = TRUE), labels = vvector),
               Berlin = factor(sample(1:5, N, replace = TRUE), labels = vvector))

(mySummary1 <- likert(c("Vegas", "NewYork", "Paris"), scales))

(mySummary2 <- likert(c("Vegas", "NewYork", "Paris"), scales,
                    labels = c("SD", "D", "N", "A", "SA")))

 ## Example of how one might write this in a file. The fn argument is not currently
 ## enabled, but the following will work.
 ## print(xtable::xtable(mySummary1, digits = 0), type = "html", file = "varCount-1.html")       
  
# }

Run the code above in your browser using DataLab