Returns a function that will return uncentered moments

moments_n(orders, cols = NULL)

Arguments

orders

Numeric with the order of the uncentered moments that will be computed.

cols

Character vector with the name of the columns of the data for which moments will be computed. If NULL, will use all columns.

Value

A function that takes a data.frame and return a named numeric vector of the uncentered moments of the columns.

See also

Examples

data <- data.frame(x = rnorm(100), y = rnorm(100)) moments_3 <- moments_n(1:3) moments_3(data)
#> x_1 x_2 x_3 y_1 y_2 y_3 #> 0.006517448 0.987434111 -0.066672201 -0.103934128 0.991432487 -0.254855242
moments_3 <- moments_n(1:3, "x") moments_3(data)
#> x_1 x_2 x_3 #> 0.006517448 0.987434111 -0.066672201