Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

map..html

Apply a function to each element of a vector or list


Description

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

  • map.() returns a list

  • _lgl.(), _int.(), _dbl.(),_chr.(), _df.() variants return their specified type

  • _dfr.() & _dfc.() Return all data frame results combined utilizing row or column binding

Usage

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

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

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

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

tidytable

Tidy Interface to 'data.table'

v0.6.1
MIT + file LICENSE
Authors
Mark Fairbanks [aut, cre], Abdessabour Moutik [ctb], Matt Carlson [ctb], Ivan Leung [ctb], Ross Kennedy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.