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)
In the end, I used the sink() function to diverts R output to a file.
sink("rules.txt")
rattle::asRules(fit, TRUE)
sink()