Data Frame Column Slice
We retrieve a data frame column slice with the single square bracket "[]" operator.
Numeric Indexing
The following is a slice containing the first column of the built-in data set mtcars.
Name Indexing
We can retrieve the same column slice by its name.
To retrieve a data frame slice with the two columns mpg and hp, we pack the column names in an index vector inside the single square bracket operator.
Tags: