You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in https://stackoverflow.com/a/56949741/590437 it would be great if map_* could produce a named list (either by default or via method parameter), if the argument is coercible to a string.
Example implementation (overwriting map in the current environment)
map = function(x, ...){
if (is.integer(x) | is.character(x)) { # this should be done in a more clever way
purrr::map(x, ...) %>% set_names(x)
}else {
purrr::map(x, ...)
}
}
1 : 5 %>% map(~ .x + 1)
The text was updated successfully, but these errors were encountered:
This is by design. Adding the names might be useful for data analysis but would make purrr harder to program with because of failed assumptions. As a package, purrr is at the intersection of data analysis and package programming, which explains this kind of design decisions.
Also the SO issue is missing the recommended solution to this problem:
As discussed in https://stackoverflow.com/a/56949741/590437 it would be great if
map_*
could produce a named list (either by default or via method parameter), if the argument is coercible to a string.Example implementation (overwriting
map
in the current environment)The text was updated successfully, but these errors were encountered: