[R] Getting runtime error in stepclass

Soma Saha ssaha at ncsu.edu
Tue Jul 5 09:55:26 CEST 2005


I got the following runtime error when I tried to use svm method with

Error in "colnames<-"(`*tmp*`, value = c("0", "1")) :
        attempt to set colnames on object with less than two dimensions

I repeated the same sequence of statements but this time I used the
classification function used in the example, i.e., "lda" and it worked
fine but I got the same error when I tried randomForest.

As the same script worked with a different classification function, I am
wondering if stepclass works with svm and randomForest.

I using R version 2.0.1 on a Linux machine. I am including the R script I
used below.

I would be grateful for any suggestion on how to make stepclass work with
these classification functions.

I would also like to make stepclass work with knn but knn does not have a
'predict' method, which is a requirement for a classification method to
work with stepclass. Is there any way to get around this?



td <- read.table("dgdata1.txt", header=TRUE, sep=",")
dgenes <- subset(td, dg == 1, select = dg:eg)
ndgenes <- subset(td, dg == 0, select = dg:eg)
n1 <- nrow(dgenes)
n2 <- nrow(ndgenes)
ndgrows <- 1:n2
selrows <- sample(ndgrows)
sndgenes <- ndgenes[selrows[1:n1],]

train <- rbind(dgenes, sndgenes)
traind <- subset(train, select = -dg)
trainr <- factor(dg)

sc_res <- stepclass(traind, trainr, "svm", direction = "forward",
criterion = "AC", fold = 10)

More information about the R-help mailing list