Re: [R] data frame manipulation with condition

2012-02-24 Thread William Dunlap
requires you to choose. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: Sarah Goslee [mailto:sarah.gos...@gmail.com] > Sent: Friday, February 24, 2012 9:39 AM > To: William Dunlap > Cc: Arnaud Gaboury; r-help@r-project.org > Subject: Re: [

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
Whatever makes you happy. > df1 <- + structure(list(x = structure(c(1L, 2L, 2L, 3L), .Label = c("AA", + "BB", "CC"), class = "factor"), y = 1:4), .Names = c("x", "y" + ), row.names = c(NA, -4L), class = "data.frame") > mult <- c("AA"=2,"BB"=5,"CC"=1,"DD"=2) > df1$y * mult[df1$x] AA BB BB CC 2 10

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
= "data.frame") Have a good weekend. Arnaud Gaboury   A2CT2 Ltd. Trade: +41 22 849 88 63 Fax:   +41 22 849 88 66 arnaud.gabo...@a2ct2.com This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are address

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
90 > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf Of Arnaud Gaboury >> Sent: Friday, February 24, 2012 8:37 AM >> To: U

Re: [R] data frame manipulation with condition

2012-02-24 Thread William Dunlap
> > > > In fact I was trying to do something with apply in one line, but couldn't > > achieve any result. In > fact, all my transformation will be multiplying one object by a specific > number according to the value > of df$x. > > In that case: > > m

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
r the use of the individual or entity to whom they are addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. If yo

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
ting. Feel free to ignore my post if you think I am lazy and disrespectful to the list. Arnaud Gaboury   A2CT2 Ltd. -----Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 17:41 To: Arnaud Gaboury Cc: r-help@r-project.org Subject:

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
---> if df$x==BB, df$y<-2*25 > 3 CC 3         NOTHING > 4 AA 40    > if df$x==AA, df$y<-4*10 > 5 DD 75   > if df$x==DD, df$y<-5*15 > 6 DD 90   > if df$x==DD, df$y<-6*15 > > Arnaud Gaboury > > A2CT2 Ltd. > > -Original Message-

Re: [R] data frame manipulation with condition

2012-02-24 Thread Uwe Ligges
==DD, df$y<-6*15 Arnaud Gaboury A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 17:07 To: Arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with condition On 24.02.2012 16:59, Arnaud

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
5 DD 75 > if df$x==DD, df$y<-5*15 6 DD 90 > if df$x==DD, df$y<-6*15 Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 17:07 To: Arnaud Gaboury Cc: r-help@r-project.org Subject: Re

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
2CT2 Ltd. >> >> >> -Original Message- >> From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] >> Sent: vendredi 24 février 2012 16:33 >> To: Arnaud Gaboury >> Cc: r-help@r-project.org >> Subject: Re: [R] data frame manipulation

Re: [R] data frame manipulation with condition

2012-02-24 Thread Uwe Ligges
boury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with condition On 24.02.2012 16:25, Arnaud Gaboury wrote: Dear list, n00b question, but still can't find any easy answer. Here is a df: Change df<-data.frame(cbind(x=c("AA","BB","CC&q

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
boury   A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 16:33 To: Arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with condition On 24.02.2012 16:25, Arnaud Gaboury wrote: > D

Re: [R] data frame manipulation with condition

2012-02-24 Thread Uwe Ligges
On 24.02.2012 16:25, Arnaud Gaboury wrote: Dear list, n00b question, but still can't find any easy answer. Here is a df: Change df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4)) to df <- data.frame(x = c("AA","BB","CC","AA"), y = 1:4) to make your object a sensible data.frame.