This generic provides a common dispatch mechanism for all regular unary mathematical functions. It is used as a common wrapper around the Summary group generics, the Math group generics, and a handful of other mathematical functions like mean().

vec_math(fun, x, ...)

vec_math_base(fun, x, ...)

Arguments

fun

An mathematical function as a string

x

A vector

...

An additional arguments.

Details

vec_base_arith() is provided as a convenience for writing methods. It calls the base fun on the underlying vec_data().

Included functions

See also

vec_arith() for the equivalent for the arithmetic infix operators.

Examples

x <- new_vctr(c(1, 2.5, 10)) x
#> <vctrs_vctr[3]> #> [1] 1.0 2.5 10.0
abs(x)
#> <vctrs_vctr[3]> #> [1] 1.0 2.5 10.0
sum(x)
#> <vctrs_vctr[1]> #> [1] 13.5
#> <vctrs_vctr[3]> #> [1] 1.0 3.5 13.5