> library(car)
> df = data.frame(value=c('A', 'B', 'C', 'A'))
> foo = recode(df$value, "'A'=1; 'B'=2; 'C'=3;", as.numeric.result=TRUE)
> mean(foo)
[1] NA
Warning message:
In mean.default(foo) : argument is not numeric or logical: returning NA
> foo
[1] 1 2 3 1
Levels: 1 2 3
Ugh. I thought the definition of as.numeric.result (default TRUE) was that if the results are all numerals, they would be coerced to numeric.
How do I get the results of this recoding to be numeric?
foo = recode(df$value, "' >A'=1; ' >B'=2; ' >C'=3;")
, please note > or < mark. I am struggling with these two marks. I cannot post another question, because it will be considered as duplicated. – Frere