On 07-02-2012, at 20:24, Arnaud Gaboury wrote:
> I did indeed have a look at recode(), and was able to replace, but an error
> warning :
>
>> recode(names,"BO","BOO",df)
> Warning message:
> In recode.default(names, "BO", "BOO", df) :
> Name(s) of vars duplicates with an object outside the dataFrame.
>
>> df
> names price
> 1 BOO 10
> 2 C 25
> 3 CL 20
>
> As you can see, "BO" has been replaced by "BOO", but with a warning!
library(car)
names<-c("BO","C","CL")
price<-c("10","25","20")
df<-data.frame(names,price)
recode(df$names,"'BO'='BOO'; 'CL'='CLO'; 'C'='CR'")
results in
[1] BOO CR CLO
Levels: BOO CLO CR
Note the single quotes.
Berend
______________________________________________
[email protected] 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.