Factors and how to create them
Working with factors
7. Counting observations, part one
Modifying factor variables
Summary

Instruction

We have the fundamentals of factors – now it's time to work with bigger data!

Let's say we are now working for an online shop for astronomy enthusiasts. Recently, we conducted a survey of 1,000 customers who bought a new telescope from us. In addition to finding out whether these customers were satisfied with their purchases, we also had customers supply their age, marital status, employment status, and primary language. The survey results are now in memory, saved in the survey tibble.

Previously, we learned how to count the number of observations in groups using group_by() and count(). Let's count how many people are in each age group. To do this, we will write:

survey %>%
  group_by(age) %>%
  count()

Exercise

Use group_by() and count() to calculate the number of people in each marital status group (the mrt_status column). Remember, you'll be using the survey dataset.

Stuck? Here's a hint!

Type:

survey %>%
  group_by(mrt_status) %>%
  count()