how to convert factor levels to integer in r

前端 未结 5 455
盖世英雄少女心
盖世英雄少女心 2021-01-21 10:50

I have following dataframe in R

  ID      Season      Year       Weekday
  1       Winter      2017       Monday
  2       Winter      2018       Tuesday
  3             


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-21 11:23

    Once you have converted the season, year and weekday to factors, use this code to change to dummy indicator variables

    contrasts(factor(dat$season) 
    contrasts(factor(dat$year)
    contrasts(factor(dat$weekday)
    

提交回复
热议问题