Good job! Another way to access a certain column of a data frame is by using an index. You can retrieve a specific column from a data frame by passing in that column's index as an argument to the bracket operator,
cities[, 1] will retrieve the first column of a data frame,
cities[, 2] will retrieve the second column, and so on. If you want to retrieve only city names for Versico's candidates, for example, you can do so like this (
city is the second column in the
citites data frame):
Notice that we need to put a coma before the column index inside the brackets. We'll explain why this comma is necessary later on.