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
21. Accessing rows and several columns
Data frame analysis
Summary

Instruction

Perfect! In the previous exercise, we retrieved only one column but you can certainly retrieve more columns by listing their names (or indexes) inside the c() function. For example, the expression

cities[cities$population > 3000000, c("city", "population")]

will retrieve city names and populations for cities with more than 3 million inhabitants.

Exercise

Extract the names and populations of countries that have more than 20 million inhabitants.

Stuck? Here's a hint!

The information about populations is stored in the population column. The names of countries are stored in the country column.