This can be used to e.g. add a maximum of certain rows.

row_function(fn, ..., data = NULL)

Arguments

fn

function to apply, such as max()

...

tidyverse selector helpers, passed on to select()

data

data set, will be determined with pick() if left blank

Examples

if (require("dplyr")) {
  iris |> 
    mutate(max = row_function(max, where(is.numeric)),
           sepal_mean = row_function(mean, starts_with("Sepal"))) |> 
    head()
}
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species max sepal_mean
#> 1          5.1         3.5          1.4         0.2  setosa 5.1       4.30
#> 2          4.9         3.0          1.4         0.2  setosa 4.9       3.95
#> 3          4.7         3.2          1.3         0.2  setosa 4.7       3.95
#> 4          4.6         3.1          1.5         0.2  setosa 4.6       3.85
#> 5          5.0         3.6          1.4         0.2  setosa 5.0       4.30
#> 6          5.4         3.9          1.7         0.4  setosa 5.4       4.65