aggregators: Combine aggregate functions and s

wrapper - s and summary funsR Documentation

Combine aggregate functions and s


[summary function_*] functions are simple wrappers of aggregate function and the s function. s removes all non-values, i.e. NA,Inf,NaN from a vector. However, if the length is 0 it returns NA. The result is then passed to the corresponding aggregation function. For example, min_(x) is identical to min(s(x)). Please read vignette("s") for more information.


max_(.x, ignore_na = TRUE)

min_(.x, ignore_na = TRUE)

sum_(.x, ignore_na = TRUE)

mean_(.x, ignore_na = TRUE)

median_(.x, ignore_na = TRUE)

sd_(.x, ignore_na = TRUE)

var_(.x, ignore_na = TRUE)

first_(.x, ignore_na = TRUE)

last_(.x, ignore_na = TRUE)


squeeze(.x, ignore_na = FALSE)

squeeze_(.x, ignore_na = TRUE)



a single vector


if false missing values are not omitted.


'first_non_na' is a faster version of 'first' since it only search for a non NA value until it finds one. 'squeeze' on the other hand checks if all elements are equal and then returns only that value.


a single aggregated value

See Also

vignette("convert"), vignette("hablar")


## sum_ on non-rational numeric vector
vector <- c(7, NaN, -Inf, 4)

## Min of vector with length 0
vector <- c()
# With a wrapped s

## Max of vector with only NA
# With a wrapped s

## Use of s when NA should not be removed
vector <- c(7, Inf, NA, 4)
# With a wrapped s
sum_(vector, ignore_na = FALSE)

hablar documentation built on March 31, 2023, 11:54 p.m.