[R] CForest Error Logical Subscript Too Long

Abigail Clifton abigailclifton at me.com
Sun Apr 29 16:53:57 CEST 2012


Hi,

This is my code (my data is attached):

library(languageR)
library(rms)
library(party)
OLDDATA <- read.csv("/Users/Abigail/Documents/OldData250412.csv")
OLDDATA$YD <- factor(OLDDATA$YD, label=c("Yes", "No")) 
OLDDATA$ND <- factor(OLDDATA$ND, label=c("Yes", "No")) 
attach(OLDDATA)
defaults <- cbind(YD, ND)
set.seed(47)
data.controls <- cforest_unbiased(ntree=500, mtry=3)
data.cforest <- cforest(defaults~LN+LV+LT+RV+MR+TL+DIA+CB, data = OLDDATA, controls=data.controls)
data.cforest.varimp <- varimp(data.cforest, conditional = TRUE)
barplot(sort(data.cforest.varimp))



And this is the error I get:

> data.cforest <- cforest(defaults~LN+LV+LT+RV+MR+TL+DIA+CB, data = OLDDATA, controls=data.controls)
Error in xt[[j]][nas, drop = FALSE] <- 0 : 
  (subscript) logical subscript too long


Basically I want to reduce the number of factors I've got (9) to fewer, say the 5 most important ones? Hence I imagined Random Forests would be a good idea. However I get the error given above. Is it possible to smarten up the code and correct the error? Or has anybody got other ideas of how I can reduce the amount of factors I have?

Kind regards,


AJC


More information about the R-help mailing list