It's generally safer to use

       as.numeric(as.character(variablename))

since it eliminates problems associated with factors.

                                       - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


On Wed, 12 Aug 2009, Daniel Malter wrote:


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 wrote:

Hi,

I'm training an SVM (C-classification from e1071 library)

Some of the variables in my data set are nominal.  Is there some
easy/automatic way to convert them to numerical representations?

Thanks,

-N

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
View this message in context: 
http://www.nabble.com/nominal-to-numeric-function-tp24930466p24939723.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to