[R] Nominal variables in SVM?

Bernd Bischl bernd_bischl at gmx.net
Thu Aug 13 13:01:29 CEST 2009


Noah Silverman wrote:
> Thanks for all the suggestions.
>
> My data was loaded in from a csv file with about 80 columns (3 of these 
> columns are nominal)  no specific settings for the nominal columns.
>
> Currently, if I call svm (e1071), I get an error about the nominal column.
>
> Do I need to tell R to change the column to a factor?  i.e. foo$color <- 
> factor(foo$color)
>
>   
That might be a possible problem, but before you try something, simply 
investigate whats wrong now:

- do str(mydata) to check columntypes of you data.frame. if somethings 
wrong there for your 3 mentioned, do indeed use as.factor (or import 
yout data in a better way)
- are you sure you use the formula interface for svm from e1071. If you 
check the help page, you will see that it clearly supports factors.

Otherwise paste str(mydata) and your call to svm here.

Bernd




More information about the R-help mailing list