What is a factor in R?

A factor in R is a specific data type that accepts categories (aka levels) from a predefined set of possible values. These categories look like characters, but under the hood, they are stored as integers. Often, such categories have an intrinsic order. For example, a column in a data frame that contains the options of the Likert scale for assessing views (“strongly agree,” “agree,” “somewhat agree,” “neither agree nor disagree,” “somewhat disagree,” “disagree,” “strongly disagree”) should be of factor type to capture this intrinsic order and adequately reflect it on the categorical types of plots.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *