Introduction to data frames
Data frame structure
5. Determining the number of columns
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

Nicely done! Similarly, ncol() takes the name of a data frame as its argument and returns number of columns the data frame contains:

ncol(cities)

R will return 5 because this is number of columns in our data frame (city name, country, longitude, latitude, and population).

Exercise

How many columns are used to store information about countries? Use the countries data frame.