[R] rpart plot question

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Wed 10 Aug 2005 - 01:30:48 EST


Dear all

I am quite confused by rpart plotting. Here is example.

set.seed(1)
y <- (c(rnorm(10), rnorm(10)+2, rnorm(10)+5)) x <- c(rep(c(1,2,5), c(10,10,10))
fit <- rpart(x~y)
plot(fit)
text(fit)

Text on first split says x < 3.5 and on the second split x < 1.5 what I understand:

If x < 3.5 so y is lower and y values go to the left split. OK. But, sometimes there is

whatever >= nnn and it seems to me that if this condition is true response variable follow to right split.

try:

y1<-(c(rnorm(10)+5,rnorm(10)+2, rnorm(10))) fit<-rpart(y1~x)
plot(fit)
text(fit)

Well, I am not sure I express myself clearly. Am I correct that when there is < sign I shall follow left node but when there is >= sign I shall follow the right one?

Best regards
Petr Pikal
Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Aug 10 01:35:15 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:45 EST