Recall & Review
beginner
What is a factor in R?
A factor in R is a data type used to represent categorical data by storing values as levels, which are distinct categories.
Click to reveal answer
beginner
Why are factors useful for categorical data?
Factors store categories as levels, which helps R handle and analyze categorical data efficiently, like grouping or summarizing.
Click to reveal answer
intermediate
How do factors differ from character vectors in R?
Factors have fixed levels representing categories, while character vectors are just strings without category information.
Click to reveal answer
intermediate
What happens if you try to add a new category to a factor without updating levels?
R will not recognize the new category and may convert it to NA (missing value) because it is not in the factor's levels.
Click to reveal answer
beginner
How can you convert a character vector to a factor in R?
Use the function factor() to convert a character vector into a factor with levels representing unique categories.Click to reveal answer
What does a factor in R represent?
✗ Incorrect
Factors represent categorical data by storing values as fixed levels.
What happens if you assign a value not in the factor levels?
✗ Incorrect
Values not in the factor levels become NA because they are unrecognized categories.
Which function converts a character vector to a factor?
✗ Incorrect
The factor() function converts character vectors to factors with levels.
Why are factors better than characters for categorical data?
✗ Incorrect
Factors store categories as levels, making grouping and analysis easier.
What type of data is best represented by factors?
✗ Incorrect
Factors represent data with distinct groups or categories.
Explain why factors are used to represent categorical data in R.
Think about how R stores and handles groups of data.
You got /4 concepts.
Describe what happens if you try to add a new category to a factor without updating its levels.
Consider how factors restrict values to predefined categories.
You got /3 concepts.