Add a new level to a factor and substitute existing one

后端 未结 3 943
傲寒
傲寒 2021-01-18 13:03

I\'m having a big trouble on dealing with levels names of a data frame.

I have a big data frame in which one of the colums is a factor with a LOT of levels.

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 13:38

    Call make.names with unique = TRUE on your column.

    df$col_foo <- factor(make.names(df$col_foo, unique = TRUE))
    

提交回复
热议问题