innerApply: Apply a function to an atomic vector using its two elements...

Description Usage Arguments Details Value Examples

View source: R/innerApply.R

Description

#' The innerApply function applies a function to an atomic vector using two of its elements in sequence as inputs. It is different from purrr::accumulate since it does not use any of its output as an input.

Usage

1
innerApply(input, .f0, distance = 1)

Arguments

input

An atomic vector.

.f0

A function. Anonymous functions are supported. Formula or vectors are not.

distance

The distance between each element of the vector. The default value is 1.

Details

If the function used as .f0 returns a vector of length higher than 1, the function will throw an error.

Value

An atomic vector of length equals length(input)-distance.

Examples

1
2
3
4
5
6
7
inputVec <- 1:30

outputVec <- innerApply(inputVec, `+`)

innerApply(letters, paste0)

innerApply(c(TRUE,FALSE,TRUE,FALSE), `!=`)

MarceloRTonon/innermap documentation built on Oct. 29, 2021, 3 p.m.