Skip to contents

This function returns the rowwise maximum value in a data frame.

Usage

gen_rowmax(data, cols)

Arguments

data

A data frame.

cols

<tidy-select> Columns to search across.

Value

A vector of the rowwise maximum value.

Details

Parallelization is supported via purrr::in_parallel().

Examples

library(dplyr, warn.conflicts = FALSE)
a <- tibble(
  x = c(1, NA, 2),
  y = c(NA, 3, NA),
  z = c(4, NA, 5)
)
gen_rowmax(a)
#> [1] 4 3 5
gen_rowmax(a, everything())
#> [1] 4 3 5
gen_rowmax(a, starts_with(letters[24:25]))
#> [1] 1 3 2
b <- a %>% mutate(q = gen_rowmax(.))
b
#> # A tibble: 3 × 4
#>       x     y     z     q
#>   <dbl> <dbl> <dbl> <dbl>
#> 1     1    NA     4     4
#> 2    NA     3    NA     3
#> 3     2    NA     5     5