[英]R - Problems with nodes() for a partykit tree
我有一个类似的问题
我想得到这样的结果。 但是,在我的情况下,nodes()函数无法正常工作。 而且我不明白为什么。
tree <- ctree(DV ~ IV, data = data)
nodes(tree, unique(where(tree)))
当我运行它时,我总是得到以下错误:
Error in match.arg(data, choices = c("all", "organization", "endpoint", :
'arg' must be NULL or a character vector
为了使该功能正常工作,我该怎么办?
提前非常感谢您!
尝试使用party
包的ctree
函数:
library(party)
set.seed(1)
x <- rnorm(100)
y <- x+runif(100)
data <- data.frame(DV=y , IV=x)
tree <- party::ctree(DV ~ IV, data = data)
nodes(tree, unique(where(tree)))
# [[1]]
# 3)* weights = 19
# [[2]]
# 6)* weights = 26
# [[3]]
# 9)* weights = 19
# [[4]]
# 8)* weights = 19
# [[5]]
# 5)* weights = 17
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.