The map functions transform their input by applying a function to each element of a list or atomic vector and returning an object of the same length as the input.
map()
always returns a list. See themodify()
family for versions that return an object of the same type as the input.map_lgl()
,map_int()
,map_dbl()
andmap_chr()
return an atomic vector of the indicated type (or die trying). For these functions,.f
must return a length-1 vector of the appropriate type.map_vec()
simplifies to the common type of the output. It works with most types of simple vectors like Date, POSIXct, factors, etc.walk()
calls.f
for its side-effect and returns the input.x
.