c_across() works inside of mutate_rowwise(). It uses tidyselect so you can easily select multiple variables.

c_across(cols = everything())

Arguments

cols

Columns to transform.

Examples

df <- data.table(x = runif(6), y = runif(6), z = runif(6))

df %>%
  mutate_rowwise(row_mean = mean(c_across(x:z)))
#> # A tidytable: 6 × 4
#>         x     y      z row_mean
#>     <dbl> <dbl>  <dbl>    <dbl>
#> 1 0.0808  0.498 0.0342    0.204
#> 2 0.834   0.290 0.320     0.481
#> 3 0.601   0.733 0.402     0.579
#> 4 0.157   0.773 0.196     0.375
#> 5 0.00740 0.875 0.404     0.429
#> 6 0.466   0.175 0.0637    0.235