library(tidyverse)
sample_df <- tibble(
x = c(1, 5, 7),
y = c(3, 2, NA)
)
sample_df |>
mutate(
# rows element-wise
min_vec = pmin(x, y, na.rm = TRUE),
max_vec = pmax(x, y, na.rm = TRUE),
# cols global
min_all = min(x, y, na.rm = TRUE),
max_all = max(x, y, na.rm = TRUE),
)