我收到此错误:
> mod1 <- ctree(Age ~ Kyphosis, data = kyphosis)
> tree.size(mod1@tree)
Error in tree.size(mod1@tree) :
trying to get slot "tree" from an object (class "constparty") that is not an S4 object
这里,tree.size 定义为:
> tree.size
function(tree) {
if (is.null(tree)) {
return(0)
} else {
return(1 + tree.size(tree$left) + tree.size(tree$right))
}
}
我如何摆脱这个错误,为什么会发生?