Last active
January 24, 2019 16:11
-
-
Save eddjberry/93c8e151db133adbfc720cbfc87dc7bf to your computer and use it in GitHub Desktop.
Different return types for selecting columns from a tibble
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a tibble---------------------- | |
tbl <- tibble::tibble(x = letters[1:5], | |
y = letters[5:1]) | |
# returns a tibble -------------------- | |
dplyr::select(tbl, x) | |
tbl[1] | |
tbl[, 1] | |
tbl["x"] | |
tbl[, "x"] | |
subset(tbl, select = "x") | |
# returns a vector -------------------- | |
dplyr::pull(tbl, x) | |
tbl[, 1, drop = TRUE] | |
tbl[[1]] | |
tbl[, "x", drop = TRUE] | |
tbl[["x"]] | |
tbl$x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment