From: Patralekha Bhattacharya <patrab_at_gmail.com>

Date: Tue 15 Mar 2005 - 23:41:34 EST

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 Tue Mar 15 23:48:23 2005

Date: Tue 15 Mar 2005 - 23:41:34 EST

Hi,

I am new to R and need help with rpart. I am trying to create a classification tree using rpart. In order to plot the reults I use the plot function and the text function to label the plot of the tree dendrogram with text. The documentation of text.rpart says : "For the "class" method, label="yval" results in the factor levels being used, "yprob" results in the probability of the winning factor level being used, and 'specific yval level' results in the probability of that factor level" . However, neither the label="yprob" option nor the label='specific yval level' option works for me. I have copied a section of my code in order to include the error message.

> plot(fit)

> text(fit, label="yprob")

Error in text.rpart(fit, label = "yprob") :

Label must be a column label of the frame component of the tree

On inspecting fit$frame I noticed that neither "yprob" nor 'specific yval level' are included in the frame. I therefore even tried to create these variable in the frame by using the following

fit$frame <- transform(fit$frame, newVar=fit$frame$yval2[,4])

where fit$frame$yval2[,4] are the probabilities of the winning factor level.

However, using this I just get the values of "yval" as the labels which I could have got anyway by setting the option label="yval".

I would really appreciate any help on this. Thanks in advance.

Pat

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 Tue Mar 15 23:48:23 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:30:47 EST
*