Description Usage Arguments Examples
Select column that are exactly the names captured unevaluated from ...
.
This is to provide a simple interface that reliably uses non-standard captured names
(and not consequences of further evaluation). Please see
https://win-vector.com/2018/09/23/a-subtle-flaw-in-some-popular-r-nse-interfaces/
for some discussion. Also accepts -name notation, but not integers or
functions of columns. Does not look at argument names (so can not be used to rename columns).
1 | select_nse(.data, ...)
|
.data |
data frame or tbl to select columns from. |
... |
unevaluated symbols to use as column names. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | y <- "x"
# returns y-column
dplyr::select(data.frame(x = 1, y = 2), y)
# returns x-column (very confusing!)
dplyr::select(data.frame(x = 1), y)
# returns y-column
select_nse(data.frame(x = 1, y = 2), y)
# deletes wrong column!
dplyr::select(data.frame(x = 1, z = 3), -y)
# throws when y is not the name of a column (good)
tryCatch(
select_nse(data.frame(x = 1), y),
error = function(e) { e }
)
#' # throws when y is not the name of a column (good)
tryCatch(
select_nse(data.frame(x = 1, z = 3), -y),
error = function(e) { e }
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.