Factors in R
Learn about factor objects in R and their use cases.
We'll cover the following...
The factor data type
Factors are beneficial when we store data as categorical variables and construct a hierarchical structure among values. The classical use case for factor data is when values in a dataset are duplicated many times, and there are a limited number of unique values.
Here is an example:
c('Small', 'Big',' Medium', 'Small', 'Big', 'Small', 'Big', 'Medium', 'Big')
# or
c(2,3,2,1,1,3,1,1,3,2,3,2)
Create factors
The factor()
function converts containers into factor ...