-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
In the example below, the function gives a 2-length result for a 1-length input. (My real case to generate this error involved changing levels for a factor, and the return value for the function was the levels and not the factor variable.)
Can the error message please be improved from
#> ! Can't compute column `A`.
#> Caused by error in `dplyr_internal_error()`:
To something indicating that the return value's length is incorrect?
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
d_test <- data.frame(A = 1)
give_two <- function(x) {
1:2
}
mutate(d_test, across("A", give_two))
#> Error in `mutate()`:
#> ℹ In argument: `across("A", give_two)`.
#> Caused by error in `across()`:
#> ! Can't compute column `A`.
#> Caused by error in `dplyr_internal_error()`:Created on 2025-12-21 with reprex v2.1.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels