max: Maxima

View source: R/max.R

maxR Documentation

Maxima

Description

Returns the maxima of the inputs.

Details

Setting na.rm = TRUE will remove NA's before calculating the maxima of the values.

max(..., na.rm = FALSE)

See Also

min(), median(), mean(), quantile()

Examples

max(c(8, 3, 2, 6))
#> [1] 8

-----------------------------------

# NA's are missing values, so since the
# first element of this vector /may/ be
# greater than 6, the max of this vector
# is unknown:

max(c(NA, 3, 2, 6))
#> [1] NA

# To drop NAs, set na.rm = TRUE:

max(c(NA, 3, 2, 6), na.rm = TRUE)
#> [1] 6

-----------------------------------

library(gapminder)

gapminder %>%
  group_by(continent) %>%
  summarize(pop_max = max(pop))

#> # A tibble: 5 x 2
#>   continent    pop_max
     <fct>          <int>
#> 1 Africa     135031164
#> 2 Americas   301139947
#> 3 Asia      1318683096
#> 4 Europe      82400996
#> 5 Oceania     20434176


cobriant/qelp documentation built on July 1, 2022, 7:24 a.m.