Skip to content

Better error message when using coord_map() without {maproj} installed #4344

@daattali

Description

@daattali

It seems that the {mapproj} package is required for coord_map() to work. The documentation for the function does talk about {mapproj} but doesn't explicitly say that the package is required.

Using the example from the function documentation this is what I get:

library(ggplot2)
library(maps)
nzmap <- ggplot(map_data("nz"), aes(x = long, y = lat, group = group)) +
  geom_polygon(fill = "white", colour = "black")
nzmap + coord_map()

Error in loadNamespace(name) : there is no package called ‘mapproj‘

When running this function in isolation it's easy enough to understand I need to install the package. However when this is part of a large codebase that runs on one machine and then is attempted to run on another machine, the error has no indication of where it came from. When uploading a shiny app to shinyapps.io, shinyapps did not pick up that it needs to install {mapproj}, and looking at the error log did not make it clear where in my app {mapproj} is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions