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
-
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("
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
It's generally safer to use
as.numeric(as.character(variablename))
since it eliminates problems associated with factors.
- Phil Spector
Statistical Computing Facility
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
5 matches
Mail list logo