Learn R Programming

tabbycat (version 0.18.0)

safe_max: 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)

Value

The max of x or NA when values are missing.

Arguments

x

A numerical vector.

na.rm

A boolean indicating whether to remove NAs.