Exercise

Mean and median

In this chapter, you'll be working with the 2018 Food Carbon Footprint Index from nu3. The food_consumption dataset contains information about the kilograms of food consumed per person per year in each country in each food category (consumption) as well as information about the carbon footprint of that food category (co2_emissions) measured in kilograms of carbon dioxide, or CO\(_2\), per person per year in each country.

In this exercise, you'll compute measures of center to compare food consumption in the US and Belgium using your dplyr skills.

dplyr is loaded for you and food_consumption is available.

Instructions 1/2

undefined XP
  • 1
    • Create two data frames: one that holds the rows of food_consumption for "Belgium" and the another that holds rows for "USA". Call these belgium_consumption and usa_consumption.
    • Calculate the mean and median of kilograms of food consumed per person per year for both countries.
  • 2
    • Filter food_consumption for rows with data about Belgium and the USA.
    • Group the filtered data by country.
    • Calculate the mean and median of the kilograms of food consumed per person per year in each country. Call these columns mean_consumption and median_consumption.