3

Recently some code I've been using to make facet maps has started to give me this warning message

Warning message:
Unknown or uninitialised column: 'region'. 

The map file I have created, called worldMap, has the following columns

"long"  "lat"   "order" "hole"  "piece" "group" "id" 

And the data source has the following columns

"scenario" "id"       "value"

The code that generates the error is

gg <- ggplot(data = d, aes(map_id = id))
gg <- gg + geom_map(aes(fill = value), map = worldMap)

If I add a new column to the map that has the value of id like this

worldMap$region <- worldMap$id

the warning message disappears. But why do I need to do this? The help text for the map option of geom_map says

It must contain columns x or long, y or lat, and region or id.

The code in geom_map that seems relevant is

stopifnot(is.data.frame(map))
    if (!is.null(map$lat)) 
        map$y <- map$lat
    if (!is.null(map$long)) 
        map$x <- map$long
    if (!is.null(map$region)) 
        map$id <- map$region

Anyway, I can solve my problem by just adding the column "region" but that seems like a kludge.

JerryN
  • 2,356
  • 1
  • 15
  • 49
  • Can you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? I tested with artificial map data where I replaced region with id, and could not reproduce the problem. – Z.Lin Jul 23 '18 at 01:38

0 Answers0