Aan de slagGa gratis aan de slag

map_chr()

In this exercise, you'll dive a bit deeper into the different map_*() variants. The map() function always outputs a list. map_*() outputs other kinds of information. Study the table below and make sure you're clear on the type of output for each map_*() variant.

map_*() Output
map_chr() character vector
map_lgl() logical vector [TRUE or FALSE]
map_int() integer vector
map_dbl() double vector

Deze oefening maakt deel uit van de cursus

Foundations of Functional Programming with purrr

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Pull out the director element of sw_films in a list and character vector
map(___, ~.x[["___"]])
map_chr(___, ~.x[["___"]])
Code bewerken en uitvoeren