编写一个函数来绘制R中的决策树

时间:2018-02-27 10:13:40

标签: r

我写了这个函数:

dec.Tree <- function(subject, formula, dfName, treePackage) {
if(treePackage == tree) library(tree)
if(treePackage == tree) churn.tree <- tree(subject ~ formula, dfName)
if(treePackage == tree) plot(churn.tree, main ="Churn Tree using tree package")
if(treePackage == tree) text(churn.tree)
}

当我运行功能代码时,它创建函数没问题,但是当我使用代码调用函数时..

dec.Tree(Churn, ., cust.Churn, tree)

它返回错误消息:

  

treePackage == tree中的错误:compare(1)仅适用于   原子和列表类型

0 个答案:

没有答案