Re: [R] nominal to numeric function

2009-08-12 Thread Daniel Malter
p-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Noah Silverman Gesendet: Wednesday, August 12, 2009 2:09 PM Cc: r-help@r-project.org Betreff: Re: [R] nominal to numeric function Hi, Thanks for the tip, Neither method works as my data is truly nominal -

Re: [R] nominal to numeric function

2009-08-12 Thread Dimitris Rizopoulos
another approach may be: foo <- c("blue", "red", "green") s.foo <- sample(foo, 20, TRUE) s.foo match(s.foo, foo) I hope it helps. Best, Dimitris Noah Silverman wrote: Hi, Thanks for the tip, Neither method works as my data is truly nominal - foo <- c("

Re: [R] nominal to numeric function

2009-08-12 Thread Noah Silverman
Hi, Thanks for the tip, Neither method works as my data is truly nominal - foo <- c("blue", "red", "green") as.numeric(foo) [1] NA NA NA Warning message: NAs introduced by coercion Rapid Miner has a function that will aut

Re: [R] nominal to numeric function

2009-08-12 Thread Phil Spector
It's generally safer to use as.numeric(as.character(variablename)) since it eliminates problems associated with factors. - Phil Spector Statistical Computing Facility

Re: [R] nominal to numeric function

2009-08-12 Thread Daniel Malter
Hi you can use newvariable=as.numeric(variablename). This converts your factors into numeric variables, but not always with the desired result. So make sure that you check whether "newvariable" gives you what you want. Otherwise recoding by hand is indicated. Best, Daniel Noah Silverman-3 wrot