Introduction to data frames
Data frame structure
Accessing columns in a data frame
Accessing rows of a data frame
Accessing rows and columns combined in a data frame
Data frame analysis
23. Filtered column analysis
Summary

Instruction

Nicely done! If you filter a data frame and extract a single column, you can apply vector analysis functions to the filtered column. For example, if you want to know how many people live in the largest French city, you can use max() like this:

max(cities[cities$country == "France", "population"])

Notice how we first filtered the data frame to only get the populations of all French cities. Then, we passed in this filtered column to the max() function to calculate the maximum value of the filtered data frame.

Exercise

Calculate the average population of countries that are in EASTERN EUROPE.

Stuck? Here's a hint!

  1. First perform row filtering:
    countries$region == "EASTERN EUROPE"
  2. Choose only the population column.
  3. Apply the mean() function on the filtered data frame.