[R] data frame manipulation with conditions

2012-02-24 Thread A2CT2 Trading
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

Re: [R] data frame manipulation with conditions

2012-02-24 Thread ilai
On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading trad...@a2ct2.com wrote: 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)) # No, your y is a factor str(df) 'data.frame': 4 obs. of 2 variables: $ x: Factor w/ 3

Re: [R] data frame manipulation with conditions

2012-02-24 Thread Arnaud Gaboury
To: A2CT2 Trading Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with conditions On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading trad...@a2ct2.com wrote: 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

Re: [R] data frame manipulation with conditions

2012-02-24 Thread ilai
Dunlap. Arnaud Gaboury A2CT2 Ltd. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ilai Sent: vendredi 24 février 2012 20:14 To: A2CT2 Trading Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with conditions