Factors are categorical vectors. Specifically, they are (integer) vectors that store categorical values, or ordinal values. Ordinal values are *ranked* categories (but they are not intervals). Factors can only contain predefined values. A classic example of a factor are male/female. An example of an ordinal (aka, ordinal) factor is education/income brackets because there is a ranking to the categories. In R, create a factor from a character vector with the command: factor(sex_char, levels = c("m", "f"). Create an ordered factor with ordered(sex_factor, levels = c("f", "m")).
David's R script is here: https://github.com/bionicturtle/youtube/tree/master/r-intro
David's R script is here: https://github.com/bionicturtle/youtube/tree/master/r-intro
Last edited: