在 R 中使用 ctree 时遇到问题,有时它根本不显示任何级别,下面是一个示例。
谁能解释为什么。谢谢
library("party")
df <- data.frame(matrix(ncol = 3, nrow = 0))
colnames(df) <- c("a", "b", "c")
df[nrow(df) + 1,] = c("Y","M","N")
df[nrow(df) + 1,] = c("Y","F","N")
df[nrow(df) + 1,] = c("Y","M","Y")
df[nrow(df) + 1,] = c("Y","F","N")
df[nrow(df) + 1,] = c("N","F","Y")
df[nrow(df) + 1,] = c("N","M","N")
df[nrow(df) + 1,] = c("N","M","Y")
df[nrow(df) + 1,] = c("N","M","N")
df[nrow(df) + 1,] = c("N","F","N")
df[nrow(df) + 1,] = c("N","F","N")
df$a <- as.factor(df$a)
df$b <- as.factor(df$b)
df$c <- as.factor(df$c)
TMDT<-ctree(a ~ b + c,data=df)
plot(TMDT,type="simple")