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
9. Accessing columns with $
Accessing rows and columns combined in a data frame
Data frame analysis
Summary

Instruction

Great job! Another popular method of accessing a single column of a data frame involves using the dollar sign ($) operator, like this:

cities$city

Basically, after you specify the data frame name, you simply type the $ sign followed by the name of the column you wish to retrieve.

In our case here with cities$city, we simply retrieve the city column from the cities data frame. Mind that the result is not the same as what you'd get with cities["city"]. The $ notation returns a vector. The brackets notation returns a data frame.

Exercise

Display the values of the column named country from the countries data frame. Use the dollar sign ($) operator.