[R] Save rules with asRules() from Rattle into dataframe

Kim C. minorthreatx at hotmail.com
Mon Feb 23 15:01:53 CET 2015


Hello, 


I use asRules from the Rattle package to make rules of a rpart decision tree: asRules(rpart1). It gives a rule such as (don't mind the data, it's merely testdata): 


 Rule number: 18 [Product=153 cover=3 (1%) prob=0.00]
   TotalChildren>=4.5
   Education=Bachelors,Partial College,Partial High School
   Gender=F
   Occupation=Skilled Manual


Then I want to save it so I use: rules <-asRules(rpart1) but it saves it as an integer. When I view "rules" I only see one column of integers. Not the data like the example above. Preferably I would like to have that data in a dataframe. 

The reproducible example can be found here: 

www.mediafire.com/download/8qqzq3qqu2mlmb1/decision+tree+rules+example.RData

The rpart tree is made with this: rpart1 <- rpart(Product ~ ., data=subset5, method="class", control=rpart.control(minbucket=2,minsplit=1, cp=-1))

Hope someone can help me out. Thanks! 		 	   		  


More information about the R-help mailing list