[R] rpart plot question

Petr Pikal petr.pikal at precheza.cz
Tue Aug 9 17:30:48 CEST 2005


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 at precheza.cz




More information about the R-help mailing list