How to debug “contrasts can be applied only to factors with 2 or more levels” error?

后端 未结 3 1487
后悔当初
后悔当初 2020-11-21 23:32

Here are all the variables I\'m working with:

str(ad.train)
$ Date                : Factor w/ 427 levels \"2012-03-24\",\"2012-03-29\",..: 4 7 12 14 19 21 24         


        
3条回答
  •  终归单人心
    2020-11-22 00:09

    Perhaps as a very quick step one is to verify that you do indeed have at least 2 factors. The quick way I found was:

    df %>% dplyr::mutate_all(as.factor) %>% str
    

提交回复
热议问题