Re: [R] Question about rpart and regression trees

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 23 Jan 2007 - 06:38:11 GMT

On Mon, 22 Jan 2007, Paul Smith wrote:

> Dear All
>
> I would like to use rpart to obtain a regression tree for a dataset
> like the following:
>
> Y X1 X2 X3 X4
> 5.500033 B A 3 2
> 0.35625148 D B 6 5
> 0.8062546 E C 4 3
> 5.100014 C A 3 2
> 5.7000422 A A 3 2
> 0.76875436 C A 6 5
> 1.0312537 D A 4 1
>
> Y is the objective variable. X1, X2, X3 and X4 can take, respectively,
> the following values:
>
> X1: A,B,C,D,E
> X2: A,B,C,D,E
> X3: 3,4,5,6
> X4. 1,2,3,4,5
>
> Should I convert X3 and X4 to factor before running rpart?

If they really are factors, yes.
If they are ordered factors, no.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Jan 23 17:42:09 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 23 Jan 2007 - 12:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.