safe_max: Calculate 'max' but suppress the warning when all values are...

View source: R/summarise.R

safe_maxR Documentation

Calculate max but suppress the warning when all values are missing

Description

This function is a drop-in replacement for max, which is used in cat_summarise. It suppresses the warning when all values are NA and na.rm is TRUE, and returns NA instead of -Inf.

Usage

safe_max(x, na.rm = FALSE)

Arguments

x

A numerical vector.

na.rm

A boolean indicating whether to remove NAs.

Value

The max of x or NA when values are missing.


olihawkins/tabbycat documentation built on Aug. 27, 2023, 10:15 a.m.