On 04-Aug-07 22:02:33, William Revelle wrote:
> Alexis and John,
> 
> To reverse a Likert like item, subtract the item from the maximum 
> acceptable value + the minimum acceptable value,
> That is, if
> x <- 1:8
> xreverse <- 9-x
> 
> Bill

A few of us have suggested this, but Alexis's welcome for the
recode() suggestion indicates that by the time he gets round to
this his Likert scale values have already become levels of a factor.

Levels "1", "2", ... of a factor may look like integers, but they're
not; and R will not let you do arithmetic on them:

> x<-factor(c(1,1,1,2,2,2))
> x
[1] 1 1 1 2 2 2
Levels: 1 2
> y<-(3-x)
Warning message: 
"-" not meaningful for factors in: Ops.factor(3, x) 
> y
[1] NA NA NA NA NA NA

However, you can turn them back into integers, reverse, and then
turn the results back into a factor:

> y <- factor(3 - as.integer(x))
> y
[1] 2 2 2 1 1 1
Levels: 1 2

So, even for factors, the insight undelying our suggestion of "-"
is still valid! :)

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Aug-07                                       Time: 00:09:58
------------------------------ XFMail ------------------------------

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to