'Why does this dplyr::select(where( statement not work (must return a boolean)?
I am using this select statement
mtcars %>%
select(
where(
function(x) is.numeric(x) | mean(x) > 10
)
)
However, I get the error saying:
Error in `dplyr::select()`:
! `where()` must be used with functions that return `TRUE` or `FALSE`.
Backtrace:
1. mtcars %>% ...
3. dplyr:::select.data.frame(...)
6. tidyselect::eval_select(expr(c(...)), .data)
7. tidyselect:::eval_select_impl(...)
16. tidyselect:::vars_select_eval(...)
...
19. tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
20. tidyselect:::walk_data_tree(new, data_mask, context_mask)
21. tidyselect:::as_indices_sel_impl(...)
23. purrr::map_lgl(data, predicate)
24. tidyselect .f(.x[[i]], ...)
But isn`t the function returning a boolean?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
