complex_map: Complex Mapping Functions

complex_mapR Documentation

Complex Mapping Functions

Description

The complex mapping functions transform the output lists from common mapping functions found in the purrr package to complex vectors.

Usage

map_cplx(.x, .f, ...)

map2_cplx(.x, .y, .f, ...)

imap_cplx(.x, .f, ...)

pmap_cplx(.l, .f, ...)

Arguments

.x

A list or atomic vector

.f

A function, formula, or vector (not necessarily atomic).

If a function, it is used as is.

If a formula, e.g. ~ .x + 2, it is converted to a function. There are three ways to refer to the arguments:

  • For a single argument function, use .

  • For a two argument function, use .x and .y

  • For more arguments, use ..1, ..2, ..3 etc

This syntax allows you to create very compact anonymous functions. Note that formula functions conceptually take dots (that's why you can use ..1 etc). They silently ignore additional arguments that are not used in the formula expression.

If character vector, numeric vector, or list, it is converted to an extractor function. Character vectors index by name and numeric vectors index by position; use a list to index by position and name at different levels. If a component is not present, the value of .default will be returned.

...

Arguments to the mapping function

.y

A vector of the same length as .x. A vector of length 1 will be recycled.

.l

A list of vectors, such as a data frame. The length of .l determines the number of arguments that .f will be called with. List names will be used if present.

Details

Supported purrr mapping functions:

purrr::map

Call .f using an argument of .x

purrr::map2

Call .f using arguments of .x and .y

purrr::imap

Call .f using arguments of .x and names(.x)

purrr::pmap

Call .f using arguments contained in .l

Value

A complex vector coerced from the mapping function and arguments

See Also

complex, purrr::map, purrr::map2


aaronmanderson3/rftk documentation built on July 30, 2023, 1:19 p.m.