Code
duckplyr_mutate(df, across(x:y, fn, .unpack = "{outer}"))
Condition
Error in `mutate()`:
i In argument: `across(x:y, fn, .unpack = "{outer}")`.
Caused by error in `across()`:
! Names must be unique.
x These names are duplicated:
* "x" at locations 1 and 2.
* "y" at locations 3 and 4.
.unpack
is validatedCode
duckplyr_summarise(df, across(x, mean, .unpack = 1))
Condition
Error in `summarise()`:
i In argument: `across(x, mean, .unpack = 1)`.
Caused by error in `across()`:
! `.unpack` must be `TRUE`, `FALSE`, or a single string, not the number 1.
Code
duckplyr_summarise(df, across(x, mean, .unpack = c("x", "y")))
Condition
Error in `summarise()`:
i In argument: `across(x, mean, .unpack = c("x", "y"))`.
Caused by error in `across()`:
! `.unpack` must be `TRUE`, `FALSE`, or a single string, not a character vector.
Code
duckplyr_summarise(df, across(x, mean, .unpack = NA))
Condition
Error in `summarise()`:
i In argument: `across(x, mean, .unpack = NA)`.
Caused by error in `across()`:
! `.unpack` must be `TRUE`, `FALSE`, or a single string, not `NA`.
Code
duckplyr_summarise(df, across(everything(), fn()))
Condition
Error in `summarise()`:
i In argument: `across(everything(), fn())`.
Caused by error in `fn()`:
! oh no!
Code
duckplyr_summarise(df, across(everything(), fn()), .by = g)
Condition
Error in `summarise()`:
i In argument: `across(everything(), fn())`.
Caused by error in `fn()`:
! oh no!
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(across(where(is.numeric), 42)))
)
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `across(where(is.numeric), 42)`.
Caused by error in `across()`:
! `.fns` must be a function, a formula, or a list of functions/formulas.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(across(y, mean))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `across(y, mean)`.
Caused by error in `across()`:
! Can't select columns that don't exist.
x Column `y` doesn't exist.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(res = across(where(
is.numeric), 42))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `res = across(where(is.numeric), 42)`.
Caused by error in `across()`:
! `.fns` must be a function, a formula, or a list of functions/formulas.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(z = across(y, mean))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `z = across(y, mean)`.
Caused by error in `across()`:
! Can't select columns that don't exist.
x Column `y` doesn't exist.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(res = sum(if_any(where(
is.numeric), 42)))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `res = sum(if_any(where(is.numeric), 42))`.
Caused by error in `if_any()`:
! `.fns` must be a function, a formula, or a list of functions/formulas.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(res = sum(if_all(~ mean(.x)))))
)
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `res = sum(if_all(~mean(.x)))`.
Caused by error in `if_all()`:
! Must supply a column selection.
i You most likely meant: `if_all(everything(), ~mean(.x))`.
i The first argument `.cols` selects a set of columns.
i The second argument `.fns` operates on each selected columns.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(res = sum(if_any(~ mean(.x)))))
)
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `res = sum(if_any(~mean(.x)))`.
Caused by error in `if_any()`:
! Must supply a column selection.
i You most likely meant: `if_any(everything(), ~mean(.x))`.
i The first argument `.cols` selects a set of columns.
i The second argument `.fns` operates on each selected columns.
Code
(expect_error(across()))
Output
<error/rlang_error>
Error in `across()`:
! Must only be used inside data-masking verbs like `mutate()`, `filter()`, and `group_by()`.
Code
(expect_error(c_across()))
Output
<error/rlang_error>
Error in `c_across()`:
! Must only be used inside data-masking verbs like `mutate()`, `filter()`, and `group_by()`.
Code
error_fn <- (function(.) {
if (all(. > 10)) {
rlang::abort("too small", call = call("error_fn"))
} else {
42
}
})
(expect_error(tibble(x = 1:10, y = 11:20) %>% duckplyr_summarise(across(
everything(), error_fn))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `across(everything(), error_fn)`.
Caused by error in `across()`:
! Can't compute column `y`.
Caused by error in `error_fn()`:
! too small
Code
(expect_error(tibble(x = 1:10, y = 11:20) %>% duckplyr_mutate(across(everything(),
error_fn))))
Output
<error/dplyr:::mutate_error>
Error in `mutate()`:
i In argument: `across(everything(), error_fn)`.
Caused by error in `across()`:
! Can't compute column `y`.
Caused by error in `error_fn()`:
! too small
Code
(expect_error(tibble(x = 1:10, y = 11:20) %>% duckplyr_summarise(force(across(
everything(), error_fn)))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `force(across(everything(), error_fn))`.
Caused by error in `across()`:
! Can't compute column `y`.
Caused by error in `error_fn()`:
! too small
Code
(expect_error(tibble(x = 1:10, y = 11:20) %>% duckplyr_mutate(force(across(
everything(), error_fn)))))
Output
<error/dplyr:::mutate_error>
Error in `mutate()`:
i In argument: `force(across(everything(), error_fn))`.
Caused by error in `across()`:
! Can't compute column `y`.
Caused by error in `error_fn()`:
! too small
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(across(everything(), list(f = mean,
f = mean)))))
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `across(everything(), list(f = mean, f = mean))`.
Caused by error in `across()`:
! Names must be unique.
x These names are duplicated:
* "x_f" at locations 1 and 2.
Code
(expect_error(duckplyr_filter(df, if_any(~ .x > 5))))
Output
<error/rlang_error>
Error in `filter()`:
i In argument: `if_any(~.x > 5)`.
Caused by error in `if_any()`:
! Must supply a column selection.
i You most likely meant: `if_any(everything(), ~.x > 5)`.
i The first argument `.cols` selects a set of columns.
i The second argument `.fns` operates on each selected columns.
Code
(expect_error(duckplyr_filter(df, if_all(~ .x > 5))))
Output
<error/rlang_error>
Error in `filter()`:
i In argument: `if_all(~.x > 5)`.
Caused by error in `if_all()`:
! Must supply a column selection.
i You most likely meant: `if_all(everything(), ~.x > 5)`.
i The first argument `.cols` selects a set of columns.
i The second argument `.fns` operates on each selected columns.
Code
(expect_error(duckplyr_filter(df, !if_any(~ .x > 5))))
Output
<error/rlang_error>
Error in `filter()`:
i In argument: `!if_any(~.x > 5)`.
Caused by error in `if_any()`:
! Must supply a column selection.
i You most likely meant: `if_any(everything(), ~.x > 5)`.
i The first argument `.cols` selects a set of columns.
i The second argument `.fns` operates on each selected columns.
Code
(expect_error(duckplyr_filter(df, !if_all(~ .x > 5))))
Output
<error/rlang_error>
Error in `filter()`:
i In argument: `!if_all(~.x > 5)`.
Caused by error in `if_all()`:
! Must supply a column selection.
i You most likely meant: `if_all(everything(), ~.x > 5)`.
i The first argument `.cols` selects a set of columns.
i The second argument `.fns` operates on each selected columns.
Code
(expect_error(df %>% duckplyr_mutate(across(1:2, ~ .y + mean(bar)))))
Output
<error/dplyr:::mutate_error>
Error in `mutate()`:
i In argument: `across(1:2, ~.y + mean(bar))`.
Caused by error in `across()`:
! Can't compute column `foo`.
Caused by error:
! the ... list contains fewer than 2 elements
Code
(expect_error(df %>% duckplyr_mutate((across(1:2, ~ .y + mean(bar))))))
Output
<error/dplyr:::mutate_error>
Error in `mutate()`:
i In argument: `(across(1:2, ~.y + mean(bar)))`.
Caused by error in `across()`:
! Can't compute column `foo`.
Caused by error in `fn()`:
! the ... list contains fewer than 2 elements
.fns
can access the .data
pronoun even when not inlinedCode
duckplyr_mutate(df, across(y, fn))
Condition
Error in `mutate()`:
i In argument: `across(y, fn)`.
Caused by error in `across()`:
! Can't compute column `y`.
Caused by error:
! Can't subset `.data` outside of a data mask context.
Code
duckplyr_mutate(df, z = c_across(c(y = x)))
Condition
Error in `mutate()`:
i In argument: `z = c_across(c(y = x))`.
Caused by error in `c_across()`:
! Can't rename variables in this context.
.cols = everything()
default with a warningCode
out <- duckplyr_mutate(df, across(.fns = times_two))
Condition
Warning:
There was 1 warning in `mutate()`.
i In argument: `across(.fns = times_two)`.
Caused by warning:
! Using `across()` without supplying `.cols` was deprecated in dplyr 1.1.0.
i Please supply `.cols` instead.
.cols = everything()
default with a warningCode
out <- duckplyr_filter(df, if_any())
Condition
Warning:
Using `if_any()` without supplying `.cols` was deprecated in dplyr 1.1.0.
i Please supply `.cols` instead.
.fns
supplied (#6638)Code
duckplyr_mutate(df, across(x, .funs = ~ . * 1000))
Condition
Error in `mutate()`:
i In argument: `across(x, .funs = ~. * 1000)`.
Caused by error in `across()`:
! `...` must be empty.
x Problematic argument:
* .funs = ~. * 1000
Code
duckplyr_summarise(df, across(everything(), mean, na.rm = TRUE))
Condition
Warning:
There was 1 warning in `summarise()`.
i In argument: `across(everything(), mean, na.rm = TRUE)`.
Caused by warning:
! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
Supply arguments directly to `.fns` through an anonymous function instead.
# Previously
across(a:b, mean, na.rm = TRUE)
# Now
across(a:b, \(x) mean(x, na.rm = TRUE))
Output
# A tibble: 1 x 1
x
<dbl>
1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.