[R] rpart with only two small groups
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed Sep 17 00:47:05 CEST 2008
On Tue, 2008-09-16 at 10:47 -0700, Birgitle wrote:
> Hello R-User!
>
> I try to do the following:
>
> New<-iris[c(1:7,90:97),1:5]
> New.rpart<-rpart(Species~., data=New, method="class")
>
> New.rpart
> n= 15
>
> node), split, n, loss, yval, (yprob)
> * denotes terminal node
>
> 1) root 15 7 versicolor (0.4666667 0.5333333) *
>
> Does it mean it is not possible to find a variable that splits my groups or
> are my groups just to small?
> Is there a way to find out the variable that splits my groups best?
Yes, as always, read the help file ;-)
?rpart leads you to ?rpart.control, which has argument minsplit with
default 20, which is the minimum number of observations in a node for a
split to be attempted. As 15 is less than 20, the root node could not be
split.
E.g.:
> New<-iris[c(1:7,90:97),1:5]
> New.rpart<-rpart(Species~., data=New, method="class", control =
rpart.control(minsplit = 2))
> New.rpart
n= 15
node), split, n, loss, yval, (yprob)
* denotes terminal node
1) root 15 7 versicolor (0.4666667 0.5333333)
2) Petal.Length< 2.5 7 0 setosa (1.0000000 0.0000000) *
3) Petal.Length>=2.5 8 0 versicolor (0.0000000 1.0000000) *
HTH
G
>
> Thanks in advance for help.
>
> B.
>
> -----
> The art of living is more like wrestling than dancing.
> (Marcus Aurelius)
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list