Re: [R] if else elseif for data frames

2012-08-14 Thread PIKAL Petr
> > 2 highH > > 3 highH > > 4 NeutralN > > 5 NeutralN > > 6 Neutral N > > 7 lowL > > 8 lowL > > 9 lowL > > 10 lowL > > > > A.K. > > > > > > > >

Re: [R] if else elseif for data frames

2012-08-13 Thread Rolf Turner
lowL A.K. - Original Message ----- From: Sachinthaka Abeywardana To: r-help@r-project.org Cc: Sent: Sunday, August 12, 2012 8:43 PM Subject: [R] if else elseif for data frames Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do t

Re: [R] if else elseif for data frames

2012-08-13 Thread arun
ot;low"="L"') dat2 #  col1 col2 #1 high    H #2  Neutral    N #3  Neutral    N #4  low    L #5 high    H #6  low    L #7  low    L #8  Neutral    N #9  Neutral    N #10    high    H A.K. ____________ From: Sachinthaka Abeywardana To:

Re: [R] if else elseif for data frames

2012-08-13 Thread arun
_ From: Sachinthaka Abeywardana To: arun Cc: R help Sent: Sunday, August 12, 2012 9:07 PM Subject: Re: [R] if else elseif for data frames The thing is I have about 10 cases. I saw the ifelse statement but was wondering if there was a cleaner method of doing it. The coding will get re

Re: [R] if else elseif for data frames

2012-08-12 Thread R. Michael Weylandt
On Sun, Aug 12, 2012 at 8:07 PM, Sachinthaka Abeywardana wrote: > The thing is I have about 10 cases. I saw the ifelse statement Note that there is no "ifelse" statement: there is only nested if/else of forms if else if else if else > but was > wondering if

Re: [R] if else elseif for data frames

2012-08-12 Thread David Winsemius
On Aug 12, 2012, at 5:43 PM, Sachinthaka Abeywardana wrote: Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='

Re: [R] if else elseif for data frames

2012-08-12 Thread Jeff Newmiller
; dat1 >>> col1 col2 >>> 1 highH >>> 2 highH >>> 3 highH >>> 4 NeutralN >>> 5 NeutralN >>> 6 NeutralN >>> 7 lowL >>> 8 lowL >>> 9 lowL >

Re: [R] if else elseif for data frames

2012-08-12 Thread jim holtman
H >> 4 NeutralN >> 5 NeutralN >> 6 NeutralN >> 7 low L >> 8 lowL >> 9 lowL >> 10 lowL >> >> A.K. >> >> >> >> >> - Original Message - >> From: Sachi

Re: [R] if else elseif for data frames

2012-08-12 Thread arun
2 1 high    H 2 high    H 3 high    H 4  Neutral    N 5  Neutral    N 6  Neutral    N 7  low    L 8  low    L 9  low    L 10 low    L A.K. - Original Message - From: Sachinthaka Abeywardana To: r-help@r-project.org Cc: Sent: Sunday, August 12, 2012 8:43 PM

Re: [R] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
highH > 2 highH > 3 highH > 4 NeutralN > 5 NeutralN > 6 NeutralN > 7 lowL > 8 lowL > 9 lowL > 10 lowL > > A.K. > > > > > ----- Original Message - > From: Sachinthaka Abey

[R] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='L' else #chuch a warning? Note that col2 was not an existin