What you've shown us looks inconsistent: The data frame you show has
variables X1 through X5 and `class'. If this is a data frame named
`data',
why do you call tree() with the formula V1 ~ X1? Where is V1?
`data' is the name of a built-in R function. Try using some other name for
the data frame. Also, give us the output of traceback() after the error
occur. That should help.
Andy
> From: NICOLAS DEIG
>
> hello,
>
> I am encoutering problems with a function of R.
> The function is for classification trees.
>
> I am working on datas of this kind:
>
> X1 X2 X3 X4 X5 class
> 1 2.092 1.902 2.779 2.944 1.946 1
>
> for 200 observations and 4 differents classes.
>
> What i would like to do is grow a tree with the function
> "tree" and then
> use the result in the function "cv.tree" in order to ran cross
> validation experiment.
> > library(tree)
> > Z<-tree(V1~X1,data)
> > W<-cv.tree(Z)
> Error in as.data.frame.default(data) : can't coerce function into a
> data.frame
>
>
> There is the problem, "cv.tree" won t consider the resluts of
function
> "tree" as an object of class tree, it just considers this object
as a
> data frame.
> Can anyone eyplain me why or already encoutered this kind of problem?
>
> THanks in advance,
> Nicolas
>
> ______________________________________________
> 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
>
>