0

Having trouble using ctree in R, sometimes it does not display any levels at all, here is an example below.

Can anyone explain why. thanks

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")
Ab Bennett
  • 1,391
  • 17
  • 24

0 Answers0