Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
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
Summary

Instruction

Great! We're making good progress. Let's now move on to row filtering. If you would like to display only specific rows of a data frame and you know their positions in the table, you can filter them like this:

cities[1, ]

Just as with columns, you define the row's position (index) in the data frame inside the brackets. As with columns, row indexes start at 1. In our case, R will retrieve the first row of the cities data frame. If we want to retrieve the fifth row of the cities data frame, we can just use the following code:

cities[5, ]

Exercise

Extract the largest country from the countries data frame. Keep in mind that the countries in the countries data frame are stored in descending order of population size.