[R] svm

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Feb 22 16:02:31 CET 2010

Hi Amy,

On Sat, Feb 20, 2010 at 9:29 PM, Amy Hessen <amy_4_5_84 at hotmail.com> wrote:
> Hi ,
> Could you please help me in this question:?
> After trying this code:
> library(e1071)
>  mydata <- as.matrix(read.delim("iris.txt"))
>  train.x <- mydata[,-1]
>  train.y <- mydata[,1]
>  mymodel <- svm(train.x, train.y, cross=3, type="C-classification")
> I receive this error:
> Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
> I put the class label in the first column.

I think you would be able to find out where many of your problems lie
if you try to provide a reproducible example we can use to test:
meaning, something I can just copy from your email and paste into my R
workspace that would reproduce your problem.

The error is telling you that something is expecting "x" to be
numeric, and it's not. So the question is, what isn't "numeric"? I
guess the answer must be in one of the two arguments you supply to the
svm function, so can you please check to see what "type" of arguments
you are passing into your function?

You can do that by running these R commands?

R> is(mydata)
R> is(train.x)
R> is(train.y)

What do you get from that?


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the R-help mailing list