Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Factors and how to create them
Working with factors
Modifying factor variables
15. Can we change factor levels?
Summary

Instruction

There are times when we may need to modify the levels of a factor – and not just by adding or removing a level. Maybe we want to take data from two levels and combine them. In this section, we'll learn how to do that.

In the astronomy store survey, there was an item that asked people to state whether they agreed or disagreed with the following statement:

"I am satisfied with this product."

They had a choice of five answers:

  • Strongly Agree,
  • Somewhat Agree,
  • Neither Agree nor Disagree,
  • Somewhat Disagree, or
  • or Strongly Disagree.

Their responses were stored in the statement column. Let's have a look.

Exercise

Check the levels of the statement factor in the survey dataset. Use the levels() function.

Stuck? Here's a hint!

Type:

levels(survey$statement)