getMin: getMin

View source: R/utilsMath.R

getMinR Documentation

getMin

Description

Get the minimum value from a vector skipping NA values. If all values are NA, returns NA.

Usage

getMin(...)

Arguments

...

numeric or character vector arguments

Value

single numeric or character element

Author(s)

STRAP team strap@epiconcept.fr

See Also

base::min() and getMax(), getMean(), getMedian() from epiuf package

Examples

# Numerics
getMin(c(1, 9))
getMin(1, 9, NA) #c() is not mandatory
getMin(as.Date("2023-01-01"), 
       NA, 
       as.Date("2023-01-31"))

# Characters
getMin(LETTERS)
## Note: For characters, getMin() will return the first month 
## according to alphabetical order (i.e., "April") 
getMin(month.name)
getMin(NA, month.name)

# If missing values
## using basic min() function from base R
min(c(1:9, NA)) #NA value takes over the other values by default
min(c(1:9, NA), na.rm = TRUE) #Need to add na.rm = TRUE to get the min value despite NAs
min(c(NA, NA), na.rm = TRUE) #If NAs only, returns Inf and a warning
## using getMin, we do not have these issues
getMin(c(NA, 1:9))
getMin(c(NA, NA))


Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.