1

I am using rattle::asRules() to display rpart decision rules to the screen, my goal is to save the rules to a tidy data frame.

Here is an example:

library(rpart)
library(rattle)

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

Desired Output: enter image description here

4

1 回答 1

0

最后,我使用 sink() 函数将 R 输出转移到文件中。

sink("rules.txt")
rattle::asRules(fit, TRUE)
sink()
于 2018-10-16T14:39:54.517 回答