reverse.levels: Reverse the levels of a factor.

Description Usage Arguments Examples

Description

Reverse the levels of a factor.

Usage

1

Arguments

x

a factor or a data.frame of factors whose levels will be reverse coded.

Examples

1
2
3
mylevels <- c('Strongly Disagree', 'Disagree', 'Neither', 'Agree', 'Strongly Agree')
test <- factor(sample(mylevels[1:5], 10, replace=TRUE))
cbind(test, as.integer(test), as.integer(reverse.levels(test)))

Example output

Loading required package: ggplot2
Loading required package: xtable
      test    
 [1,]    2 2 3
 [2,]    1 1 4
 [3,]    4 4 1
 [4,]    4 4 1
 [5,]    4 4 1
 [6,]    2 2 3
 [7,]    3 3 2
 [8,]    3 3 2
 [9,]    4 4 1
[10,]    3 3 2

likert documentation built on May 2, 2019, 11:11 a.m.