Selecting multiple elements with [

df[rows, cols] selecting just one column:

  • with a tibble you still get a data frame (tibble)
  • but with a data.frame simplification to vector is applied:
    • except df[rows, cols, drop = FALSE]: maintains the data.frame class
df
##   x y     z
## 1 1 k FALSE
## 2 2 l  TRUE
df[, "z"]
## [1] FALSE  TRUE
df[, "z", drop = FALSE]
##       z
## 1 FALSE
## 2  TRUE