patriciagraf at aon.at
2012-Mar-05 20:52 UTC
[R] decision/classification trees with fewer than 20 objects
Hi! I'm trying to construct and plot a decision tree to class a set of only 8 objects and tried to use the rpart and tree function, but get a error message both times: rpart: fit is not a tree, just a root tree: cannot plot singlenode tree I read in the post 'question regression trees' that rpart doesn't split a set of fewer than 20 objects...so I guess the same holds true for the tree function? My questions therefore are: How can I change the function arguments in either the rpart or the tree function so they work for a set of less than 20 objects? I looked at the function body, but since I'm new to R, I couldn't find the according argument. Or is there any other decision tree function for small datasets? Many Thanks, Patricia
Prof Brian Ripley
2012-Mar-06 05:59 UTC
[R] decision/classification trees with fewer than 20 objects
On 05/03/2012 20:52, patriciagraf at aon.at wrote:> Hi! > > I'm trying to construct and plot a decision tree to class a set of only 8 objects and tried to use the rpart and tree function, but get a error message both times: > > rpart: fit is not a tree, just a root > > tree: cannot plot singlenode tree > > I read in the post 'question regression trees' that rpart doesn'tsplit a set of fewer than 20 objects...so I guess the same holds true for the tree function? We have no idea what 'post' that is, but don't believe everything you read on the internet. In is good practice to give URLs for references.> My questions therefore are: > > How can I change the function arguments in either the rpart or thetree function so they work for a set of less than 20 objects? I looked at the function body, but since I'm new to R, I couldn't find the according argument. You need to read the help pages, ?rpart and ?tree control: a list of options that control details of the ?rpart? algorithm. See ?rpart.control?. control: A list as returned by ?tree.control?. We could tell you what options you needed (and had you followed the posting guide and given us a reproducible example, we might have), but for 'new to R', following help files is an essential skill.> Or is there any other decision tree function for small datasets? > > Many Thanks, > Patricia > > ______________________________________________ > R-help at r-project.org 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.-- Brian D. Ripley, ripley at 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