StrongDisStrongAgr: Strongly disagree to Strongly agree

Description Usage Arguments Value Author(s) Examples

Description

Gives "strongly disagree" to "strongly agree" response option labels to variables.

Usage

1
StrongDisStrongAgr(dat, vars, ros, ord=TRUE)

Arguments

dat

the data frame

vars

a single variable or a list of multiple variables

ros

the number of response options; currently supports 5 or 7

ord

logical indicating whether the items should be ordinal (TRUE:default) or factor (FALSE)

Value

This function will return response option labels for ordered factors.

Author(s)

Seth Berry, Michael Clark

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(dat, vars, ros, ord=TRUE){
  require(dplyr)
  datReduced = select(dat, one_of(vars))
  if(ros == 7)
    likOrd = lapply(datReduced, function(x)
      factor(x,
             levels = c(1,2,3,4,5,6,7),
             labels = c("Strongly disagree", "Disagree", "Somewhat disagree",
                        "Neither disagree nor agree", "Somewhat agree",
                        "Agree", "Strongly agree"),
             ordered=ord)
    )
  else {
    datReduced = select(dat, one_of(vars))
    likOrd = lapply(datReduced, function(x)
      factor(x,
             levels = c(1,2,3,4,5),
             labels = c("Strongly disagree", "Disagree",
                        "Neither disagree nor agree",
                        "Agree", "Strongly agree"),
             ordered=ord)
    )  
  }
  likOrd = as.data.frame(likOrd)
  dat[,vars] = likOrd
}

saberry/lkrt documentation built on May 7, 2019, 2:32 p.m.