helpersFun: Higher Order Helpers for Vector Comprehension

Description Usage Arguments Details Value Functions Examples

Description

These functions use a vector and a function to create an iterable object that can be used for vector comprehension.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
starmap(x, f, axis = 0, ..., longest = TRUE, fill = NULL)

starred(x, f, axis = 0, ..., longest = TRUE, fill = NULL)

starfilter(x, f, axis = 0, ..., longest = TRUE, fill = NULL)

partition(x, f, ...)

dropwhile(x, f, ...)

takewhile(x, f, ...)

Arguments

x

vector

f

function to be applied to x

axis

which axis to perform different operations? axis=0, the default, performs operations on each element in the list (columns), while axis=1 performs operations on each object within the elements of a list (rows).

...

additional arguments passed to lower functions. See funprog

longest

logical; should the longest item be used to determine the new length or shortest? Defaults to TRUE.

fill

object with which to fill the vector when operating on elements with varying lengths or shifts.

Details

The star functions are similar to their funprog counterparts, except that they are applied one level deeper in the list.

Value

list or other vector

Functions

Examples

1
2
3
4
5
6
7
8
9
x <- list(1:3, 4:6, 7:9)

## filter away values less than 6
starfilter(x, ~.i > 5)
starfilter(x, ~.i > 5, axis=1) # Transposed

starred(x, `/`, init=1) # sequentially divide each item, starting at 1

partition(x, ~.i > 5)

cmann3/eList documentation built on Jan. 25, 2021, 6:17 a.m.