TimTeaFan / dplyover

Create columns by applying functions to vectors and/or columns in 'dplyr'.
https://timteafan.github.io/dplyover/
Other
61 stars 0 forks source link

`across2()` does not tell `mutate()` the correct used variables #22

Closed psychelzh closed 11 months ago

psychelzh commented 11 months ago

See the following example:

dat <- withr::with_seed(
  1,
  data.frame(
    id = 1:5,
    x1 = rnorm(5),
    x2 = rnorm(5)
  )
)
dat |> 
  dplyr::mutate(
    dplyover::across2(
      x1:x2, x1:x2,
      cor
    ),
    .keep = "unused"
  )
#>   x1_x1 x2_x2
#> 1     1     1
#> 2     1     1
#> 3     1     1
#> 4     1     1
#> 5     1     1

Created on 2023-12-10 with reprex v2.0.2

When specifying .keep = "unused", it is expected that id column is kept.

TimTeaFan commented 11 months ago

Duplicate of #1