Applies a function to the unlisted elements of a list

funlist(alist, f, ...)

Arguments

alist

a list

f

a function to be applied

...

further arguments passed on to f

Value

value

Author

Gaston Sanchez

See also

Examples

# say you have some list
list1 = list(1:5, runif(3), rnorm(4))

# get the sum of all elements in list1
funlist(list1, sum)
#> [1] 17.04764

# get the maximum element in list1
funlist(list1, max)
#> [1] 5

# say you have missing data
list2 = list(c(1:4, NA), runif(3), rnorm(4))

# get the sum removing NAs
funlist(list2, sum, na.rm=TRUE)
#> [1] 12.88671