Sorry, I wasn't very helpful. Let me try this again. I have attached a subsample of the data which still gives me the same error as when I use the full data file. I am trying to make a decision tree using rpart. This is my code and output. > data <- read.table("/Users/randygriffiths/Desktop/data", header=T) > attach(data) > > library(rpart) > bookings.cart <- rpart(totalRev~., data=data, method="class") > bookings.cart n= 50
node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 50 15 0 (0.7 0.04 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02) * > summary(bookings.cart) Call: rpart(formula = totalRev ~ ., data = data, method = "class") n= 50 CP nsplit rel error 1 0 0 1 Error in yval[, 1] : incorrect number of dimensions I have used rpart on past projects without any problems. I can do a regression tree without any error as well (by leaving off the method="class" argument). I have used this same data using 'randomForest' with good results and also using 'tree' without this error. I have seen that at least a few people have reported getting this same error with rpart, but I could not find an answer that helped the problem. Can anyone help me? Randy On Jan 30, 2008 2:33 AM, Uwe Ligges <[EMAIL PROTECTED]> wrote: > > > Randy Griffiths wrote: > > I am trying to make a decision tree using rpart. The function runs very > > quickly considering the size of the data (1742, 163). When I call the > > summary command I get this: > > > >> summary(bookings.cart) > > Call: > > rpart(formula = totalRev ~ ., data = bookings, method = "class") > > n=1741 (1 observation deleted due to missingness) > > > > CP nsplit rel error > > 1 0 0 1 > > Error in yval[, 1] : incorrect number of dimensions > > > > > And we get: > > R> summary(bookings.cart) > Error in summary(bookings.cart) : object "bookings.cart" not found > > hence we cannot reproduce and inspect your problem. Please read the > posting guide. > > Uwe Ligges > > > > note: > >> dim(bookings) > > [1] 1742 163 > > > > > > I have run rpart on past projects without any problems. I have used a > > catagorical version of the variable totalRev that was partitioned into > four > > levels (and coded as a factor). > > I tried making a tree with the tree command (in the 'tree' package) and > was > > able to construct a tree without any errors. However, I would much > rather > > use rpart. > > > > Does anyone have any ideas that might help? > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@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. >
______________________________________________ R-help@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.