I have an example of dataset where decision tree (rpart) would not split, even with cp = 0. Here is link to the date unsplittable. I think even if you take purely random dataset, it will split, it is pretty hard to find something that does not split completely. I am trying to compute splits manually and see any improvements in Gini index. Here is my code anyway:
library(rpart)
df<- read_csv(file = 'df.csv')
df$x <- as.factor(df$x)
fit <- rpart(x ~ ., method = 'class',
data = df,
control = rpart.control(cp=0))
summary(fit)
printcp(fit)
And here is output:
Classification tree:
rpart(formula = x ~ ., data = df, method = "class", control = rpart.control(cp = 0))
Variables actually used in tree construction:
character(0)
Root node error: 16/186 = 0.086022
n= 186
CP nsplit rel error xerror xstd
1 0 0 1 0 0