ggplot2 masking purrr::map automatically


Hi all,

I often find myself getting into a situation like this when using the tidyverse and plotting geo-data:


map(1:2, identity)
#> [[1]]
#> [1] 1
#> [[2]]
#> [1] 2

map_data("world") %>% 
  dplyr::filter(region == "Greenland") %>% 
  ggplot(aes(x = long, y = lat)) +
  geom_polygon(aes(group = group))
#> Attaching package: 'maps'
#> The following object is masked from 'package:purrr':
#>     map

map(1:2, identity)
#> Error in paste("(^", regions, ")", sep = "", collapse = "|"): cannot coerce type 'closure' to vector of type 'character'

It's not a massive deal, since I can just call purrr::map explicitly, although it is a bit annoying and can often interrupt my workflow.

Is there any way to call ggplot2::map_data without attaching maps::map into the current environment*?

* Also, have I got the terminology correct, here?

1 Like


You could check out the package conflicted. It allows you to declare session-wide preferences so your workflow is less interrupted.

1 Like


Yes, this looks fantastic, thank you.

The import package linked at the bottom looks really nice, too!

1 Like


If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

closed #5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.