Working With Factors in R | Convert Categorical Variable into Factors

4K views May 16, 2024
publisher-humix

thedatahall.com

Verified Humix Creator Badge

In this video we work with factor variables in R. We start with defining the factor variable using factor() and as.factor() functions from base R. Then we discuss the fct() function from the forcats package. We move on the dropping unused levels using fct_drop(), modifying factors order using fct_relevel(), fct_infreq(), fct_rev() and fct_reorder(). Lastly, we discuss modifying factor levels using fct_recode and fct_collapse. 00:00 Install packages 1:52 Defining factors using factor() 6:26 as.factor() 7:48 fct() from forcats 10:18 Dropping unused levels 12:14 Manually Modifying factors order 13:49 Order based on frequency 15:44 Order based on values of another variable 17:19 Modifying factors levels (fct_recode) 18:36 Factor collapse (fct_collapse) Website: thedatahall.com As an Amazon Associate, I earn from qualifying purchases.


View Video Transcript
#Computer Science
#Mathematics
#Statistics