[R] data frame manipulation with condition
Arnaud Gaboury
arnaud.gaboury at a2ct2.com
Fri Feb 24 16:25:26 CET 2012
Dear list,
n00b question, but still can't find any easy answer.
Here is a df:
> df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4))
> df
x y
1 AA 1
2 BB 2
3 CC 3
4 AA 4
I want to modify this df this way :
if df$x=="AA" then df$y=df$y*10
if df$x=="BB" then df$y=df$y*25
and so on with other conditions.
TY for any help.
Trading
A2CT2 Ltd.
Arnaud Gaboury
A2CT2 Ltd.
More information about the R-help
mailing list