Hi all,
I often find myself getting into a situation like this when using the tidyverse and plotting geo-data:
library(purrr)
library(ggplot2)
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
Ranae
November 22, 2018, 2:03pm
2
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
cderv
November 24, 2018, 9:04am
4
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:
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
1 Like
system
Closed
December 1, 2018, 9:04am
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.