"Error in cat...argument 1 (type 'list') cannot be handled by cat"

Hello everyone. I'm a beginner with this program.I find this error when making an analysis through decision trees.

> str(nba)
tibble [100 x 5] (S3: tbl_df/tbl/data.frame)
 $ PG    : num [1:100] 78 77 72 64 69 60 64 78 80 82 ...
 $ PI    : num [1:100] 78 77 72 64 69 60 64 78 80 82 ...
 $ MPG   : num [1:100] 36.8 36.9 32.8 33.7 33.8 34 35 34.6 35.5 34.9 ...
 $ PPG   : num [1:100] 36.1 28 27.7 27.5 27.3 26.6 26.6 26 25.8 25.6 ...
 $ SALARY: num [1:100] 30570000 30560700 24157304 25467250 37457154 ...


> setup<-tree.control(nrow(nba), mincut=5,minsize = 10,mindev = 0.10)
> n_trees<-tree(SALARY~MPG+PPG,control=setup)
> n_trees
Error in cat(x, ..., sep = sep) : 
  argument 1 (type 'list') cannot be handled by 'cat'

Running "n_trees", I should find this type of output:
Cattura2

Can anyone help me understand where the problem comes from? Thanks.

which decision tree package are you using ?

I'm using "tree" package and, as suggested by cran.r-project, using also "MASS" package.

it seems you ommitted a data = argument to the tree function call, it has only the formula and control params. However, I would have thought therefore that the tree() call would have errored, rather than appearing to complete and only erroring when you want to display...
had you done something to attach the dataset to the environment to let the tree() work without the data param ?

A reproducible example would be useful. seems nba is only 100x5 , which seems it would be small enough to communicate here fully. You could do so with the dput() function.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.