[R] Help needed on switch function

2010-06-09 Thread Megh Dal
Hi all, Here I am trying to implement the switch() function to choose value of a variable depending on the value of an input variable :   temp1 - 1   temp1.name - switch(temp1,   1 == aa,   2 == bb,    

Re: [R] Help needed on switch function

2010-06-09 Thread Joris Meys
R is confused about the type in the switch, reads it as numeric instead of a character. Try : temp1.name - switch(temp1, 1 = aa, 2 = bb, 3 = cc, 4 =

Re: [R] Help needed on switch function

2010-06-09 Thread Joris Meys
PS : use a single = instead of a double. It's an assignment you do, not a comparison. Cheers Joris On Wed, Jun 9, 2010 at 2:14 PM, Joris Meys jorism...@gmail.com wrote: R is confused about the type in the switch, reads it as numeric instead of a character. Try :              temp1.name -