STAT1003 – Statistical Techniques
Dr. Emi Tanaka
Australian National University
These slides are best viewed on a modern browser like Google Chrome on a desktop or laptop. Some interactive components may require some time to fully load.
ToothGrowth$dose: 0.5, 1.0 and 2.0)factor] instead of [character]? as.numeric function returns the internal integer values of the factor
You probably want to use:
NAforcats package is part of tidyversestringr package the main functions in forcats prefix with fct_ or lvls_ and the first argument is a factor (or a character) vectorfct_anonfct_cfct_collapsefct_countfct_crossfct_dropfct_expandfct_explicit_nafct_infreqfct_inorderfct_inseqfct_lumpfct_lump_lowfreqfct_lump_minfct_lump_nfct_lump_propfct_matchfct_na_level_to_valuefct_na_value_to_levelfct_otherfct_recodefct_relabelfct_relevelfct_reorderfct_reorder2fct_revfct_shiftfct_shufflefct_unifyfct_uniquelvls_expandlvls_reorderlvls_revaluelvls_uniongss_cat is a dataset in forcats package from the General Social Survey (GSS) that contains a number of categorical variables.fct_lump* functions:
fct_lump_n: lump all levels except the n most frequentfct_lump_min: lump together those less than min countsfct_lump_prop: lump together those less than proportion of propfct_lump_lowfreq: lump up least frequent levels such that the Other level is still the smallest levelfct_lump gss_cat datasetforcats cheatsheet

STAT1003 – Statistical Techniques