Prior to dplyr 1.0.0, when the scoped variants of verbs had not yet been superseded, I wrote several custom functions that allowed for user-defined arguments to be passed along to dplyr functions. I have been working to update the syntax of some of these functions since the release of dplyr 1.0 (and functions such as across(), if_any(), if_all() etc.), but I've been struggling with updating the function in the reprex below.
The purpose of this function is to allow a user to filter a dataset where all user-selected columns in an observation are NA. The original function does not use dot-dot-dot (...) notation to accept these arguments, but I am trying to make the updated function accept a ..., and use the most recent version of dplyr. Any thoughts on how to do this given the examples?
Standard output and standard error
Error: Can't combine <quosures> and <logical>.
Backtrace:
█
1. ├─global::function_new_dplyr(example_table, a, b)
2. │ └─`%<>%`(...)
3. ├─dplyr::filter(., dplyr::across(dplyr::vars(!!!columns), ~dplyr::any_vars(!is.na(.))))
4. ├─dplyr:::filter.data.frame(...)
5. │ └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
6. │ ├─base::withCallingHandlers(...)
7. │ └─mask$eval_all_filter(dots, env_filter)
8. ├─dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))
9. │ └─dplyr:::across_setup(...)
10. │ └─tidyselect::eval_select(cols, data = across_cols)
11. │ └─tidyselect:::eval_select_impl(...)
12. │ ├─tidyselect:::with_subscript_errors(...)
13. │ │ ├─base::tryCatch(...)
14. │ │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
15. │ │ │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
16. │ │ │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
17. │ │ └─tidyselect:::instrument_base_errors(expr)
18. │ │ └─base::withCallingHandlers(...)
19. │ └─tidyselect:::vars_select_eval(...)
20. │ └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
21. │ └─tidyselect:::as_indices_sel_impl(...)
22. │ └─tidyselect:::as_indices_impl(x, vars, strict = strict)
23. │ └─vctrs::vec_as_subscript(x, logical = "error")
24. └─vctrs:::try_catch_impl(...)
25. ├─base::tryCatch(try_catch_callback(data, NULL), ...)
26. │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
27. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
28. │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
29. └─vctrs:::try_catch_callback(data, NULL)
30. └─(function () ...
31. └─vctrs::vec_default_ptype2(...)
32. └─vctrs::stop_incompatible_type(...)
33. └─vctrs:::stop_incompatible(...)
34. └─vctrs:::stop_vctrs(...)
Error: Can't combine <quosures> and <integer>.
Backtrace:
█
1. ├─global::function_new_dplyr(example_table, a, b)
2. │ └─`%<>%`(...)
3. ├─dplyr::filter(., dplyr::across(dplyr::vars(!!!columns), ~dplyr::any_vars(!is.na(.))))
4. ├─dplyr:::filter.data.frame(...)
5. │ └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
6. │ ├─base::withCallingHandlers(...)
7. │ └─mask$eval_all_filter(dots, env_filter)
8. ├─dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))
9. │ └─dplyr:::across_setup(...)
10. │ └─tidyselect::eval_select(cols, data = across_cols)
11. │ └─tidyselect:::eval_select_impl(...)
12. │ ├─tidyselect:::with_subscript_errors(...)
13. │ │ ├─base::tryCatch(...)
14. │ │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
15. │ │ │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
16. │ │ │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
17. │ │ └─tidyselect:::instrument_base_errors(expr)
18. │ │ └─base::withCallingHandlers(...)
19. │ └─tidyselect:::vars_select_eval(...)
20. │ └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
21. │ └─tidyselect:::as_indices_sel_impl(...)
22. │ └─tidyselect:::as_indices_impl(x, vars, strict = strict)
23. │ └─vctrs::vec_as_subscript(x, logical = "error")
24. └─vctrs:::try_catch_impl(...)
25. ├─base::tryCatch(try_catch_callback(data, NULL), ...)
26. │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
27. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
28. │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
29. └─vctrs:::try_catch_callback(data, NULL)
30. └─(function () ...
31. └─vctrs::vec_default_ptype2(...)
32. └─vctrs::stop_incompatible_type(...)
33. └─vctrs:::stop_incompatible(...)
34. └─vctrs:::stop_vctrs(...)
Error: Can't combine <quosures> and <character>.
Backtrace:
█
1. ├─global::function_new_dplyr(example_table, a, b)
2. │ └─`%<>%`(...)
3. ├─dplyr::filter(., dplyr::across(dplyr::vars(!!!columns), ~dplyr::any_vars(!is.na(.))))
4. ├─dplyr:::filter.data.frame(...)
5. │ └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
6. │ ├─base::withCallingHandlers(...)
7. │ └─mask$eval_all_filter(dots, env_filter)
8. ├─dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))
9. │ └─dplyr:::across_setup(...)
10. │ └─tidyselect::eval_select(cols, data = across_cols)
11. │ └─tidyselect:::eval_select_impl(...)
12. │ ├─tidyselect:::with_subscript_errors(...)
13. │ │ ├─base::tryCatch(...)
14. │ │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
15. │ │ │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
16. │ │ │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
17. │ │ └─tidyselect:::instrument_base_errors(expr)
18. │ │ └─base::withCallingHandlers(...)
19. │ └─tidyselect:::vars_select_eval(...)
20. │ └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
21. │ └─tidyselect:::as_indices_sel_impl(...)
22. │ └─tidyselect:::as_indices_impl(x, vars, strict = strict)
23. │ └─vctrs::vec_as_subscript(x, logical = "error")
24. └─vctrs:::try_catch_impl(...)
25. ├─base::tryCatch(try_catch_callback(data, NULL), ...)
26. │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
27. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
28. │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
29. └─vctrs:::try_catch_callback(data, NULL)
30. └─(function () ...
31. └─vctrs::vec_default_ptype2(...)
32. └─vctrs::stop_incompatible_type(...)
33. └─vctrs:::stop_incompatible(...)
34. └─vctrs:::stop_vctrs(...)
Error: Must subset elements with a valid subscript vector.
x Subscript has the wrong type `quosures`.
ℹ It must be numeric or character.
Backtrace:
█
1. ├─global::function_new_dplyr(example_table, a, b)
2. │ └─`%<>%`(...)
3. ├─dplyr::filter(., dplyr::across(dplyr::vars(!!!columns), ~dplyr::any_vars(!is.na(.))))
4. ├─dplyr:::filter.data.frame(...)
5. │ └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
6. │ ├─base::withCallingHandlers(...)
7. │ └─mask$eval_all_filter(dots, env_filter)
8. └─dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))
9. └─dplyr:::across_setup(...)
10. └─tidyselect::eval_select(cols, data = across_cols)
11. └─tidyselect:::eval_select_impl(...)
12. ├─tidyselect:::with_subscript_errors(...)
13. │ ├─base::tryCatch(...)
14. │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
15. │ │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
16. │ │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
17. │ └─tidyselect:::instrument_base_errors(expr)
18. │ └─base::withCallingHandlers(...)
19. └─tidyselect:::vars_select_eval(...)
20. └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
21. └─tidyselect:::as_indices_sel_impl(...)
22. └─tidyselect:::as_indices_impl(x, vars, strict = strict)
23. └─vctrs::vec_as_subscript(x, logical = "error")
Error: Must subset columns with a valid subscript vector.
x Subscript has the wrong type `quosures`.
ℹ It must be numeric or character.
Backtrace:
█
1. ├─global::function_new_dplyr(example_table, a, b)
2. │ └─`%<>%`(...)
3. ├─dplyr::filter(., dplyr::across(dplyr::vars(!!!columns), ~dplyr::any_vars(!is.na(.))))
4. ├─dplyr:::filter.data.frame(...)
5. │ └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
6. │ ├─base::withCallingHandlers(...)
7. │ └─mask$eval_all_filter(dots, env_filter)
8. └─dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))
9. └─dplyr:::across_setup(...)
10. └─tidyselect::eval_select(cols, data = across_cols)
11. └─tidyselect:::eval_select_impl(...)
12. ├─tidyselect:::with_subscript_errors(...)
13. │ ├─base::tryCatch(...)
14. │ │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
15. │ │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
16. │ │ └─base:::doTryCatch(return(expr), name, parentenv, handler)
17. │ └─tidyselect:::instrument_base_errors(expr)
18. │ └─base::withCallingHandlers(...)
19. └─tidyselect:::vars_select_eval(...)
20. └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
21. └─tidyselect:::as_indices_sel_impl(...)
22. └─tidyselect:::as_indices_impl(x, vars, strict = strict)
23. └─vctrs::vec_as_subscript(x, logical = "error")
Error: Problem with `filter()` input `..1`.
ℹ Input `..1` is `dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))`.
x Must subset columns with a valid subscript vector.
x Subscript has the wrong type `quosures`.
ℹ It must be numeric or character.
Backtrace:
█
1. ├─global::function_new_dplyr(example_table, a, b)
2. │ └─`%<>%`(...)
3. ├─dplyr::filter(., dplyr::across(dplyr::vars(!!!columns), ~dplyr::any_vars(!is.na(.))))
4. ├─dplyr:::filter.data.frame(...)
5. │ └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
6. │ ├─base::withCallingHandlers(...)
7. │ └─mask$eval_all_filter(dots, env_filter)
8. ├─dplyr::across(dplyr::vars(a, b), ~dplyr::any_vars(!is.na(.)))
9. │ └─dplyr:::across_setup(...)
10. │ └─tidyselect::eval_select(cols, data = across_cols)
11. │ └─tidyselect:::eval_select_impl(...)
12. │ └─tidyselect:::with_subscript_errors(...)
13. │ └─base::tryCatch(...)
14. │ └─base:::tryCatchList(expr, classes, parentenv, handlers)
15. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
16. │ └─value[[3L]](cond)
17. │ └─rlang::cnd_signal(cnd)
18. ├─rlang:::signal_abort(x)
19. │ └─base::stop(fallback)
20. └─(function (e) ...