Code
select_loc(letters2, starts_with("a") || ends_with("b"))
Condition
Error in `select_loc()`:
! Can't use scalar `||` in selections.
i Do you need `|` instead?
Code
select_loc(letters2, starts_with("a") && ends_with("b"))
Condition
Error in `select_loc()`:
! Can't use scalar `&&` in selections.
i Do you need `&` instead?
*
and ^
in data contextCode
select_loc(letters2, a * 2)
Condition
Error in `select_loc()`:
! Can't use arithmetic operator `*` in selection context.
Code
select_loc(letters2, a^2)
Condition
Error in `select_loc()`:
! Can't use arithmetic operator `^` in selection context.
Code
vars <- c("a", "b")
select_loc(letters2, vars)
Condition
Warning:
Using an external vector in selections was deprecated in tidyselect 1.1.0.
i Please use `all_of()` or `any_of()` instead.
# Was:
data %>% select(vars)
# Now:
data %>% select(all_of(vars))
See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
Output
a b
1 2
Code
select_loc(iris, where(is.factor), allow_predicates = FALSE)
Condition
Error in `select_loc()`:
! This tidyselect interface doesn't support predicates.
Code
# Foreign errors during evaluation
select_loc(iris, eval_tidy(foobar))
Condition
Error in `select_loc()`:
i In argument: `eval_tidy(foobar)`.
Caused by error:
! object 'foobar' not found
Code
x <- select_loc(x, .data$a)
Condition
Warning:
Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
i Please use `"a"` instead of `.data$a`
Code
x <- select_loc(x, .data[[var]])
Condition
Warning:
Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
i Please use `all_of(var)` (or `any_of(var)`) instead of `.data[[var]]`
Code
# Using a predicate without where() warns
invisible(select_loc(iris, is_integer))
Condition
Warning:
Use of bare predicate functions was deprecated in tidyselect 1.1.0.
i Please use wrap predicates in `where()` instead.
# Was:
data %>% select(is_integer)
# Now:
data %>% select(where(is_integer))
Code
invisible(select_loc(iris, is.numeric))
Condition
Warning:
Use of bare predicate functions was deprecated in tidyselect 1.1.0.
i Please use wrap predicates in `where()` instead.
# Was:
data %>% select(is.numeric)
# Now:
data %>% select(where(is.numeric))
Code
invisible(select_loc(iris, isTRUE))
Condition
Warning:
Use of bare predicate functions was deprecated in tidyselect 1.1.0.
i Please use wrap predicates in `where()` instead.
# Was:
data %>% select(isTRUE)
# Now:
data %>% select(where(isTRUE))
Code
# Warning is not repeated
invisible(select_loc(iris, is_integer))
Condition
Warning:
Use of bare predicate functions was deprecated in tidyselect 1.1.0.
i Please use wrap predicates in `where()` instead.
# Was:
data %>% select(is_integer)
# Now:
data %>% select(where(is_integer))
Code
# formula shorthand must be wrapped
(expect_error(select_loc(mtcars, ~ is.numeric(.x))))
Output
<error/rlang_error>
Error in `select_loc()`:
! Formula shorthand must be wrapped in `where()`.
# Bad
data %>% select(~is.numeric(.x))
# Good
data %>% select(where(~is.numeric(.x)))
Code
(expect_error(select_loc(mtcars, ~ is.numeric(.x) || is.factor(.x) ||
is.character(.x))))
Output
<error/rlang_error>
Error in `select_loc()`:
! Formula shorthand must be wrapped in `where()`.
# Bad
data %>% select(~is.numeric(.x) || is.factor(.x) || is.character(.x))
# Good
data %>% select(where(~is.numeric(.x) || is.factor(.x) || is.character(.x)))
Code
(expect_error(select_loc(mtcars, ~ is.numeric(.x) || is.factor(.x) ||
is.character(.x) || is.numeric(.x) || is.factor(.x) || is.character(.x))))
Output
<error/rlang_error>
Error in `select_loc()`:
! Formula shorthand must be wrapped in `where()`.
# Bad
data %>% select(~...)
# Good
data %>% select(where(~...))
Code
(expect_error(select_loc(mtcars, .data$"foo")))
Output
<error/rlang_error>
Error in `select_loc()`:
! The RHS of `.data$rhs` must be a symbol.
Code
ensure_named(integer(), allow_empty = FALSE)
Condition
Error:
! Must select at least one item.
Code
ensure_named(integer(), allow_empty = FALSE, allow_rename = FALSE)
Condition
Error:
! Must select at least one item.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.