Session Ready
Exercise

How many are there? - Part one

Let's have a look at the number of BSc, MSc & PhD holders in the US. To do this you need to calculate the number of observations there are for each Degree in ac_survey_clean.

To do create grouped summaries, you can combine group_by() and summarize(), both from the dplyr package.

This command groups ac_survey_clean by Degree, and then calculates the average way by Degree (try it out in the console!):

ac_survey_clean %>%
  group_by(Degree) %>%
  summarize(avg_wage = mean(PINCP))
Instructions
100 XP
  • Use a combination of group_by() and summarize() to create a summary data frame that contains the number of observations for each Degree. You can use the dplyr-specific aggregate function n() (without arguments) to count the number of observations in a group. Call this summary column count. Assign the resulting data frame to degree_holders.
  • Print out degree_holders; does the output make sense?