apply_at_index: Apply a Function to List Elements at Given Index

Description Usage Arguments Examples

View source: R/utils.R

Description

Apply a Function to List Elements at Given Index

Usage

1
apply_at_index(x, i, fun, ..., prefix = NULL)

Arguments

x

a list or a data frame (which is in fact a list)

i

vector of indices of elements in x to which the function fun is to be applied

fun

function to be applied

...

further arguments passed to fun

prefix

optional. String used to prefix the names of the elements to which the function was applied. By default the name of the function fun is used as a prefix

Examples

1
2
3
4
5
(x <- list(a = 1, b = 2, c = 3))
fhpredict:::apply_at_index(x, i = -1, fun = exp)

(x <- data.frame(a = -(1:2), b = -(2:3), c = c("a", "b")))
fhpredict:::apply_at_index(x, i = -3, fun = abs)

KWB-R/fhpredict documentation built on Nov. 1, 2020, 5:58 a.m.