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.

______________________________________________
R-help@r-project.org 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