map: Apply a function to each element of a vector

Description Usage Arguments Value See Also Examples

Description

The map functions transform their input by applying a function to each element and returning a vector the same length as the input.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
map(.x, .f, ...)

map_if(.x, .p, .f, ..., .else = NULL)

map_at(.x, .at, .f, ...)

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

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

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

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

map_raw(.x, .f, ...)

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

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

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

map_depth(.x, .depth, .f, ..., .ragged = FALSE)

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.

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.

...

Additional arguments passed on to the mapped function.

.p

A single predicate function, a formula describing such a predicate function, or a logical vector of the same length as .x. Alternatively, if the elements of .x are themselves lists of objects, a string indicating the name of a logical element in the inner lists. Only those elements where .p evaluates to TRUE will be modified.

.else

A function applied to elements of .x for which .p returns FALSE.

.at

A character vector of names, positive numeric vector of positions to include, or a negative numeric vector of positions to exlude. Only those elements corresponding to .at will be modified. If the tidyselect package is installed, you can use vars() and the tidyselect helpers to select elements.

.id

Either a string or NULL. If a string, the output will contain a variable with that name, storing either the name (if .x is named) or the index (if .x is unnamed) of the input. If NULL, the default, no variable will be created.

Only applies to _dfr variant.

.depth

Level of .x to map on. Use a negative value to count up from the lowest level of the list.

  • map_depth(x, 0, fun) is equivalent to fun(x).

  • map_depth(x, 1, fun) is equivalent to x <- map(x, fun)

  • map_depth(x, 2, fun) is equivalent to x <- map(x, ~ map(., fun))

.ragged

If TRUE, will apply to leaves, even if they're not at depth .depth. If FALSE, will throw an error if there are no elements at depth .depth.

Value

All functions return a vector the same length as .x.

map() returns a list, map_lgl() a logical vector, map_int() an integer vector, map_dbl() a double vector, and map_chr() a character vector. map_df(), map_dfc(), map_dfr() all return a data frame. The output of .f will be automatically typed upwards, e.g. logical -> integer -> double -> character.

If .x has names(), the return value preserves those names.

walk() returns the input .x (invisibly). This makes it easy to use in pipe.

See Also

Other map variants: imap, invoke, lmap, map2, modify

Examples

 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
1:10 %>%
  map(rnorm, n = 10) %>%
  map_dbl(mean)

# Or use an anonymous function
1:10 %>%
  map(function(x) rnorm(10, x))

# Or a formula
1:10 %>%
  map(~ rnorm(10, .x))

# The names of the input are preserved in the output:
list(foo = 1, bar = 2) %>% map(`+`, 10)

# Using set_names() with character vectors is handy to keep track
# of the original inputs:
set_names(c("foo", "bar")) %>% map_chr(paste0, ":suffix")

# Extract by name or position
# .default specifies value for elements that are missing or NULL
l1 <- list(list(a = 1L), list(a = NULL, b = 2L), list(b = 3L))
l1 %>% map("a", .default = "???")
l1 %>% map_int("b", .default = NA)
l1 %>% map_int(2, .default = NA)

# Supply multiple values to index deeply into a list
l2 <- list(
  list(num = 1:3,     letters[1:3]),
  list(num = 101:103, letters[4:6]),
  list()
)
l2 %>% map(c(2, 2))

# Use a list to build an extractor that mixes numeric indices and names,
# and .default to provide a default value if the element does not exist
l2 %>% map(list("num", 3))
l2 %>% map_int(list("num", 3), .default = NA)


# Use a predicate function to decide whether to map a function:
map_if(iris, is.factor, as.character)

# Specify an alternative with the `.else` argument:
map_if(iris, is.factor, as.character, .else = as.integer)

# A more realistic example: split a data frame into pieces, fit a
# model to each piece, summarise and extract R^2
mtcars %>%
  split(.$cyl) %>%
  map(~ lm(mpg ~ wt, data = .x)) %>%
  map(summary) %>%
  map_dbl("r.squared")

# Use map_lgl(), map_dbl(), etc to reduce to a vector.
# * list
mtcars %>% map(sum)
# * vector
mtcars %>% map_dbl(sum)

# If each element of the output is a data frame, use
# map_dfr to row-bind them together:
mtcars %>%
  split(.$cyl) %>%
  map(~ lm(mpg ~ wt, data = .x)) %>%
  map_dfr(~ as.data.frame(t(as.matrix(coef(.)))))
# (if you also want to preserve the variable names see
# the broom package)

# Use `map_depth()` to recursively traverse nested vectors and map
# a function at a certain depth:
x <- list(a = list(foo = 1:2, bar = 3:4), b = list(baz = 5:6))
str(x)
map_depth(x, 2, paste, collapse = "/")

# Equivalent to:
map(x, map, paste, collapse = "/")

Example output

 [1] 0.9886654 2.3424747 3.2956559 4.3113175 5.0082491 5.7701139 7.2762984
 [8] 7.9147819 8.7492343 9.9120678
[[1]]
 [1] -0.31713571 -1.82477886  1.27923910 -0.13778419  1.80609952  0.31849223
 [7]  2.90453227  0.20374507 -0.07574473  0.18349950

[[2]]
 [1]  1.71556943  0.83883648  1.81340129  2.48400320  1.42928470 -0.05839535
 [7]  0.74259499  2.84941401  0.94115807  2.79077741

[[3]]
 [1] 5.5785422 0.7503794 3.7161410 2.8397331 1.7600123 3.1183062 4.6101163
 [8] 1.3734169 2.8130359 2.3372320

[[4]]
 [1] 3.666258 4.205269 4.471508 4.564200 4.862184 3.384224 4.568410 4.054239
 [9] 4.213449 4.694625

[[5]]
 [1] 4.833737 4.318009 4.952965 7.224601 6.876476 5.352719 4.223992 5.593595
 [9] 5.452018 5.810526

[[6]]
 [1] 6.440580 5.016879 5.941477 7.824910 6.398555 6.079256 5.373399 7.493940
 [9] 7.593041 6.679359

[[7]]
 [1] 6.766481 8.205152 5.984837 8.491631 7.917819 4.658742 6.982481 7.129032
 [9] 6.557065 8.026128

[[8]]
 [1] 10.562656  7.206479  8.779482  9.504028  8.925468  8.922587  8.353509
 [8]  8.823325  6.998985  8.797485

[[9]]
 [1]  9.511385  7.625748  8.023133 10.308377  9.874112  9.814735  9.795769
 [8]  7.740503  8.513368 10.861848

[[10]]
 [1] 10.456503 10.954396 11.122283 10.303084  9.016577 11.280625 10.193416
 [8]  9.732536 11.552596  9.695719

[[1]]
 [1]  1.10736746  0.81347147  1.18503882  1.16352611 -0.06330874  0.68512926
 [7]  1.41422076  1.11097599  2.15619486  1.30760161

[[2]]
 [1] 4.22853326 2.45828255 0.99285122 0.02064199 1.71458122 1.74042183
 [7] 3.27209417 2.39079552 2.17233563 1.31255348

[[3]]
 [1] 4.318586 2.853841 2.228605 2.177744 4.099914 3.181960 3.597139 2.584438
 [9] 3.964833 2.817603

[[4]]
 [1] 5.885967 3.277167 5.105045 2.516285 4.842313 2.717181 4.648766 5.281317
 [9] 2.130930 3.467609

[[5]]
 [1] 5.147097 6.480304 5.034263 4.284619 7.326265 2.788386 4.678170 4.532168
 [9] 7.132248 7.582579

[[6]]
 [1] 6.359330 6.981532 6.189761 6.821925 4.772957 6.502479 4.573255 6.969031
 [9] 4.974829 4.902275

[[7]]
 [1] 7.188723 7.642713 6.362155 7.648708 8.421288 7.424226 7.735400 6.624905
 [9] 6.182102 8.073832

[[8]]
 [1] 10.095404  7.279893  8.466515  8.960319  9.961744  8.052449  8.106965
 [8]  7.867227  6.193950  8.695773

[[9]]
 [1]  9.381420 10.757272 10.221208  8.248213  7.885739  7.699005  7.652776
 [8] 10.603707 10.244224  7.616996

[[10]]
 [1]  9.418086  8.636790 10.050510  9.426732 10.646211 10.006311  8.343272
 [8] 11.227233 10.522587  9.976034

$foo
[1] 11

$bar
[1] 12

         foo          bar 
"foo:suffix" "bar:suffix" 
[[1]]
[1] 1

[[2]]
[1] "???"

[[3]]
[1] "???"

[1] NA  2  3
[1] NA  2 NA
[[1]]
[1] "b"

[[2]]
[1] "e"

[[3]]
NULL

[[1]]
[1] 3

[[2]]
[1] 103

[[3]]
NULL

[1]   3 103  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 0.3 0.2 0.4 0.2 0.5 0.2 0.2 0.4 0.2 0.2 0.2 0.2 0.4 0.1 0.2 0.2 0.2
 [37] 0.2 0.1 0.2 0.2 0.3 0.3 0.2 0.6 0.4 0.3 0.2 0.2 0.2 0.2 1.4 1.5 1.5 1.3
 [55] 1.5 1.3 1.6 1.0 1.3 1.4 1.0 1.5 1.0 1.4 1.3 1.4 1.5 1.0 1.5 1.1 1.8 1.3
 [73] 1.5 1.2 1.3 1.4 1.4 1.7 1.5 1.0 1.1 1.0 1.2 1.6 1.5 1.6 1.5 1.3 1.3 1.3
 [91] 1.2 1.4 1.2 1.0 1.3 1.2 1.3 1.3 1.1 1.3 2.5 1.9 2.1 1.8 2.2 2.1 1.7 1.8
[109] 1.8 2.5 2.0 1.9 2.1 2.0 2.4 2.3 1.8 2.2 2.3 1.5 2.3 2.0 2.0 1.8 2.1 1.8
[127] 1.8 1.8 2.1 1.6 1.9 2.0 2.2 1.5 1.4 2.3 2.4 1.8 1.8 2.1 2.4 2.3 1.9 2.3
[145] 2.5 2.3 1.9 2.0 2.3 1.8

$Species
  [1] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
  [6] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [11] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [16] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [21] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [26] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [31] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [36] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [41] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [46] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [51] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [56] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [61] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [66] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [71] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [76] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [81] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [86] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [91] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [96] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
[101] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[106] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[111] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[116] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[121] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[126] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[131] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[136] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[141] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[146] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 

$Sepal.Length
  [1] 5 4 4 4 5 5 4 5 4 4 5 4 4 4 5 5 5 5 5 5 5 5 4 5 4 5 5 5 5 4 4 5 5 5 4 5 5
 [38] 4 4 5 5 4 4 5 5 4 5 4 5 5 7 6 6 5 6 5 6 4 6 5 5 5 6 6 5 6 5 5 6 5 5 6 6 6
 [75] 6 6 6 6 6 5 5 5 5 6 5 6 6 6 5 5 5 6 5 5 5 5 5 6 5 5 6 5 7 6 6 7 4 7 6 7 6
[112] 6 6 5 5 6 6 7 7 6 6 5 7 6 6 7 6 6 6 7 7 7 6 6 6 7 6 6 6 6 6 6 5 6 6 6 6 6
[149] 6 5

$Sepal.Width
  [1] 3 3 3 3 3 3 3 3 2 3 3 3 3 3 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 3 3 3
 [38] 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 2 2 2 3 2 2 2 2 3 2 2 2 3 3 2 2 2 3 2 2 2
 [75] 2 3 2 3 2 2 2 2 2 2 3 3 3 2 3 2 2 3 2 2 2 3 2 2 2 2 3 2 3 2 3 3 2 2 2 3 3
[112] 2 3 2 2 3 3 3 2 2 3 2 2 2 3 3 2 3 2 3 2 3 2 2 2 3 3 3 3 3 3 3 2 3 3 3 2 3
[149] 3 3

$Petal.Length
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 3 4 3 3 4 4 4 3 4 4 4 4 3 4 4 4 4
 [75] 4 4 4 5 4 3 3 3 3 5 4 4 4 4 4 4 4 4 4 3 4 4 4 4 3 4 6 5 5 5 5 6 4 6 5 6 5
[112] 5 5 5 5 5 5 6 6 5 5 4 6 4 5 6 4 4 5 5 6 6 5 5 5 6 5 5 4 5 5 5 5 5 5 5 5 5
[149] 5 5

$Petal.Width
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 2 1 1 1 2 2
[112] 1 2 2 2 2 1 2 2 1 2 2 2 1 2 1 1 1 2 1 1 2 2 1 1 2 2 1 1 2 2 2 1 2 2 2 1 2
[149] 2 1

$Species
  [1] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
  [6] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [11] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [16] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [21] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [26] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [31] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [36] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [41] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [46] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"    
 [51] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [56] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [61] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [66] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [71] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [76] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [81] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [86] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [91] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
 [96] "versicolor" "versicolor" "versicolor" "versicolor" "versicolor"
[101] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[106] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[111] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[116] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[121] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[126] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[131] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[136] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[141] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
[146] "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 

        4         6         8 
0.5086326 0.4645102 0.4229655 
$mpg
[1] 642.9

$cyl
[1] 198

$disp
[1] 7383.1

$hp
[1] 4694

$drat
[1] 115.09

$wt
[1] 102.952

$qsec
[1] 571.16

$vs
[1] 14

$am
[1] 13

$gear
[1] 118

$carb
[1] 90

     mpg      cyl     disp       hp     drat       wt     qsec       vs 
 642.900  198.000 7383.100 4694.000  115.090  102.952  571.160   14.000 
      am     gear     carb 
  13.000  118.000   90.000 
  (Intercept)        wt
1    39.57120 -5.647025
2    28.40884 -2.780106
3    23.86803 -2.192438
List of 2
 $ a:List of 2
  ..$ foo: int [1:2] 1 2
  ..$ bar: int [1:2] 3 4
 $ b:List of 1
  ..$ baz: int [1:2] 5 6
$a
$a$foo
[1] "1/2"

$a$bar
[1] "3/4"


$b
$b$baz
[1] "5/6"


$a
$a$foo
[1] "1/2"

$a$bar
[1] "3/4"


$b
$b$baz
[1] "5/6"

purrr documentation built on May 2, 2019, 8:31 a.m.