map.: Apply a function to each element of a vector or list

Description Usage Arguments Examples

View source: R/map.R

Description

The map functions transform their input by applying a function to each element and returning a list/vector/data.table.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
map.(.x, .f, ...)

map_lgl.(.x, .f, ...)

map_int.(.x, .f, ...)

map_dbl.(.x, .f, ...)

map_chr.(.x, .f, ...)

map_dfc.(.x, .f, ...)

map_dfr.(.x, .f, ..., .id = NULL)

map_df.(.x, .f, ..., .id = NULL)

walk.(.x, .f, ...)

map2.(.x, .y, .f, ...)

map2_lgl.(.x, .y, .f, ...)

map2_int.(.x, .y, .f, ...)

map2_dbl.(.x, .y, .f, ...)

map2_chr.(.x, .y, .f, ...)

map2_dfc.(.x, .y, .f, ...)

map2_dfr.(.x, .y, .f, ..., .id = NULL)

map2_df.(.x, .y, .f, ..., .id = NULL)

Arguments

.x

A list or vector

.f

A function

...

Other arguments to pass to a function

.id

Whether map_dfr.() should add an id column to the finished dataset

.y

A list or vector

Examples

1
2
3
4
5
map.(c(1,2,3), ~ .x + 1)

map_dbl.(c(1,2,3), ~ .x + 1)

map_chr.(c(1,2,3), as.character)

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.