[R] "Where" command in ctree (party)

Achim Zeileis Achim.Zeileis at uibk.ac.at
Sat Feb 18 10:41:27 CET 2012


On Fri, 17 Feb 2012, Joseph Wang wrote:

>
> I was able to narrow down to a column that has different types using
>
> featurefields<-c(7, 17, 19, 20, 22, 33, 35, 36, 38, 44:132)
> flag <- rep(0, ncol(data))
> for (i in featurefields) {
> 	flag[i] <- class(data[,i]) != class(validdata[,i])
> }

A construct like

which(sapply(data, class) != sapply(validdata, class))

might also help.

> It is an integer class in the training data but is numeric in the 
> validation data even though unique(valid[,88]) shows 0 and 1.

Hopefully valid[,88] <- as.integer(valid[,88]) should then resolve the 
problems.
Z

>
> -----Original Message-----
> From: Achim Zeileis [mailto:Achim.Zeileis at uibk.ac.at]
> Sent: Friday, February 17, 2012 10:51 AM
> To: Joseph Wang
> Cc: r-help at r-project.org
> Subject: Re: [R] "Where" command in ctree (party)
>
> On Fri, 17 Feb 2012, josephw wrote:
>
>> i run class(). Both have the same class.
>
> Without a reproducible example it is hard to say what is going on here.
> All columns of the learning and the test data need to have (a) the same name, (b) the same class, (c) the same levels in case they are factors.
>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Where-command-in-ctree-party-tp3264187p4
>> 397693.html Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at 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.
>>
>
>



More information about the R-help mailing list