Reading rpart Input Parameters from a Text Variable

前端 未结 2 1026
自闭症患者
自闭症患者 2021-01-20 14:03

I\'m using rpart to make a decision tree. For example:

fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)

How do

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-20 14:35

    Use as.formula:

    rpart_formula <- as.formula(
        paste("Kyphosis ~ ", 
              paste(predictor_variables, collapse = " + "), 
              sep = ""
        )
    )
    

提交回复
热议问题