getMin | R Documentation |
Get the minimum value from a vector skipping NA values. If all values are NA, returns NA.
getMin(...)
... |
numeric or character vector arguments |
single numeric or character element
STRAP team strap@epiconcept.fr
base::min()
and getMax()
, getMean()
,
getMedian()
from epiuf
package
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.