[R] (no subject)
Liaw, Andy
andy_liaw at merck.com
Fri Dec 17 14:46:12 CET 2004
> -----Original Message-----
> From: NICOLAS DEIG
>
> hello,
>
> i am encoutering problems with a function of R concerning the
> classification trees.
>
> In the library {tree}, when I use the function "tree" to grow a
^^^^^^^
That should be "package"...
> classification tree it should give me an object of class
> "tree". Then I
> should be allowed to use this "tree" object in the function "cv.tree"
> that requires an object of class "tree" in order to run a
> cross-validation experiment.
> There is the problem, when I do this the following message appears:
> "Error in as.data.frame.default(data) : can't coerce function into a
> data.frame".
> So instead of considering the object as an object of class tree the
> function "cv.tree" handles it like a data.frame.
>
> Does anyone knows why or how to work on a class "tree" object so that
> "cv.tree" can handle it?
Please show how you did it the the error you got. I can't reproduce the
problem you described:
> library(tree)
> iris.tree <- tree(Species ~ ., iris)
> iris.cvtree <- cv.tree(iris.tree)
> iris.cvtree
$size
[1] 6 5 4 3 2 1
$dev
[1] 52.33779 45.94317 46.28027 63.43450 151.84608 335.57375
$k
[1] -Inf 4.228650 4.717398 15.957916 95.676543 190.954250
$method
[1] "deviance"
attr(,"class")
[1] "prune" "tree.sequence"
Andy
> Thanks in advance...
> Nicolas Deig
>
> ______________________________________________
> R-help at 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
>
>
More information about the R-help
mailing list