I have a dataset (Node1) which contains 6 brands and on applying ctree(), the same is split into 2 terminal nodes. Node2 contains 4 brands Node3 contains 2 brands. I would like to extract these brands of each terminal node and store them in two different dataframes. Please suggest how to do the same.
This is what I have coded :
library("party")
library(gridExtra)
fileName <- "C\\"
data <- read.csv(paste(fileName, ".csv", sep=""), header=TRUE)
pdd <- subset(data, select=c(col1,col2))
pdd_ctree <- ctree(col1~col2, data=pdd, controls = ctree_control(minsplit=30))
print(pdd_ctree@tree$psplit$splitpoint[1:6])
print(pdd_ctree@tree$psplit$splitpoint)
The result that I get is :
print(pdd_ctree@tree$psplit$splitpoint[1:6])
[1] 1 0 1 1 0 1
print(pdd_ctree@tree$psplit$splitpoint)
[1] 1 0 1 1 0 1
attr(,"levels")
[1] "Brand01" "Brand02" "Brand03" "Brand04"
[5] "Brand05" "Brand06"
My requirement :
Have 2 dataframes left.df and right.df
left.df will contain [Brand01,Brand03,Brand04,Brand06]
right.df will contain [Brand02,Brand05]