Introduction
A factor in R is used to store categorical data. It helps group values into categories, making it easier to analyze and summarize data.
When you have survey answers like 'Yes', 'No', or 'Maybe' and want to treat them as categories.
When you want to group data by types, such as colors: 'Red', 'Blue', 'Green'.
When preparing data for graphs that show categories instead of numbers.
When you want to save memory by storing repeated category labels efficiently.