[R] SVM error.

Jim Lemon drjimlemon at gmail.com
Wed Jun 3 11:34:51 CEST 2015


Hi Pijush,
First, please keep the messages on the help list.

As far as I can determine, the "x" in your code above is a matrix of
character strings. When you transpose (t) the initial data frame, all
of the numbers are coerced to character mode as the columns must all
be of the same mode. The first column, being of character mode, causes
all of the other columns to be coerced to character. What you may want
to do is something like this:

FilterData<-NoemalisedData[,-1]
TFilterData <- t(FilterData)
x<-TFilterData
is.numeric(x)
[1] TRUE

This removes the first column of NoemalisedData so that the remaining
columns are numeric, and remain so after the transpose. If you are
using "svm" from the e1071 package, this might solve your problem.

Jim



On Wed, Jun 3, 2015 at 5:09 PM, Pijush Das <topijush at gmail.com> wrote:
> Hi Jim,
>
>
> First of all thank you for your immediate reply.
>
> please find the attachment. I am sending two excel file where
> the the first file (Data) contained the raw data and the list is also
> given in another file and the code has been send before. The variable named
> "NoemalisedData" is used to get the value from Data.excel file.
>
>
>
> Please try and send me the code. I am also trying it in my way.
>
> Thank you.
>
>
>
> With Regards
> Pijush
>
>
> On Wed, Jun 3, 2015 at 12:04 PM, Jim Lemon <drjimlemon at gmail.com> wrote:
>>
>> Hi Pijush,
>> Without access to the data, we can only guess. However, in such cases
>> the problem is often a factor variable where you expect a numeric one.
>> Try this:
>>
>> is.factor(x)
>>
>> and if the answer is TRUE, you have found your problem.
>>
>> Jim
>>
>>
>> On Wed, Jun 3, 2015 at 4:13 PM, Pijush Das <topijush at gmail.com> wrote:
>> > Dear Sir,
>> >
>> > I am facing an error when I am trying to use svm and found similar kind
>> > of
>> > problem faced by other. But I unable to solve the problem. The problem
>> > is
>> > given below.
>> >
>> >> rm(list=ls(all=TRUE))
>> >> CombinedGeneList <- read.xlsx(file.choose(), sheet = 1, colNames =
>> > TRUE,rowNames = TRUE)
>> >> NoemalisedData <- read.xlsx(file.choose(), sheet=1,colNames =
>> > TRUE,rowNames = TRUE)
>> >> status<-NoemalisedData[1, ]
>> >> FilterData <-NoemalisedData[rownames(CombinedGeneList), ]
>> >> TFilterData <- t(FilterData)
>> >> Tstatus <- t(status)
>> >> x<-TFilterData
>> >> y<-Tstatus
>> >> model <- svm( x, y)
>> > Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
>> >>
>> >
>> >
>> >
>> > Please solve the problem. I have tried it in many ways.
>> > Waiting for your reply.
>> > Thank you
>> >
>> >
>> >
>> > With regards
>> > Pijush
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.
>
>



More information about the R-help mailing list