R Factor Data Type | R Datatypes Factors - r - learn r - r programming
- In datatypes, arrays are a special vector.
- Arrays are similar to matrices but we can have more than two dimensions.
- Factors are the data objects which are used to categorize the data and store it as levels.
- They can store both strings and integers.
- They are useful in the columns which have a limited number of unique values. Like "Male, "Female" and True, False etc.
- They are useful in data analysis for statistical modeling.
- Factors are created using the factor () function by taking a vector as input.
- wikitechy is specifying to string variable. Here ('1','1','2','4','3','3','2','1') is data elements.
- Here in this example, factor(wikitechy) is used to create an objects of wikitechy variable.
- Here print() is used to print the value, that value stored in wikitechy variable.
- The nlevels(wikitechy)) functions is gives the count of levels.
- Here in this output we display 1 1 2 4 3 3 2 1 which specifying to data elements. The levels of a factor are used when displaying the factor's values 1 2 3 4.
- Here in this output we display 4 which specifies to count of levels.