[R] Problem with the recode function

Alain Guillet alain.guillet at uclouvain.be
Tue Jun 15 16:57:56 CEST 2010


Hello,

I am using the recode() function in Rcmdr and the result is not what I 
expect so I am almost sure I did something wrong but what...

 > test <- data.frame(x=1:10)
 > library(car)
 > recode(test$x,'1:5=0 ; else=1', as.factor.result=TRUE)
  [1] 0 0 0 0 0 1 1 1 1 1
Levels: 0 1

BUT

 > library(Rcmdr)  #  recode from the car package is now masked

Now I recode test$x through the Rmcdr interface and I get the following 
code :
test$variable <- recode(test$x, '1:5 = 0; else = 1; ', 
as.factor.result=FALSE)
  And a vector of NA as result.

 > test$variable
[1] NA NA NA NA NA NA NA NA NA NA

I am using R 2.11.1 with Rcmdr 1.5-5 on Windows Vista.


Regards,
Alain

-- 
Alain Guillet
Statistician and Computer Scientist

SMCS - IMMAQ - Université catholique de Louvain
Bureau c.316
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50



More information about the R-help mailing list