Re: [R] rpart plot question

From: John Field <>
Date: Thu 11 Aug 2005 - 19:41:53 EST

Petr Pikal wrote:

Dear all

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


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) ## NB should be y~x



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.


y1<-(c(rnorm(10)+5,rnorm(10)+2, rnorm(10)))




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 If instead of rpart you use mvpart, ie

fit <- mvpart(y~x, data=data.frame(cbind(x,y))) plot(fit)

then the plot will be much clearer about the condition for splits.

summary(fit) will also help.


John Field Consulting Pty Ltd
10 High St, Burnside SA 5066, Australia
ph: +61 8 8332 5294 or +61 409 097 586
fax: +61 8 8332 1229
email: mailing list PLEASE do read the posting guide! Received on Thu Aug 11 19:48:17 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:13:58 EST