Skip to content

Can we improve on this across() error? #6712

@DavisVaughan

Description

@DavisVaughan
library(dplyr)

df <- tibble(x = 1:2, y = 3:4)

fn <- function(col) {
  stop("oh no")
}

mutate(df, across(y, fn))
#> Error in `mutate()`:
#> ℹ In argument: `across(y, fn)`.
#> Caused by error in `across()`:
#> ! Can't compute column `y`.
#> Caused by error:
#> ! oh no

It can probably just be:

#> Error in `mutate()`:
#> ℹ In argument: `across(y, fn)`.
#> ℹ In column: `y`.
#> Caused by error:
#> ! oh no

As mentioned here #6704 (comment)

Thrown from here, so seems plausible that we could improve on this

dplyr/R/mutate.R

Lines 382 to 388 in 49b39af

chunks <- withCallingHandlers(
mask$eval_all_mutate(quo),
error = function(cnd) {
msg <- glue("Can't compute column `{quo_data$name_auto}`.")
abort(msg, call = call("across"), parent = cnd)
}
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions