I'm getting errors here:
library(ggmap)
library(maptools)
library(maps)
library(ggplot2)
library(fiftystater)
library(reshape2)
data("fifty_states")
map_stats <- read.csv(file.choose())
ggplot(map_stats, aes(fill = statename, map_id = state)) +
geom_map(map = fifty_states) +
expand_limits(x = fifty_states$long, y = fifty_states$lat) +
coord_map() +
theme(legend.position = "bottom",
panel.background = element_blank())
I'm basically following along with this example in this library: https://github.com/wmurphyrd/fiftystater
I'm trying to replicate this graph: https://i.imgur.com/DwIMgql.jpg
using this data set: https://i.imgur.com/Aj03Jrm.jpg (its all fifty states but you get the idea).
Currently I'm getting a blank plot pane one of two errors:
Error in FUN(X[[i]], ...) : object 'state' not found
or
Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (54): fill, map_id
dputso we can avoid retyping the data? I think your problem is thatmap_idneeds to be shared across both thefiftystaterdata and the plot data, as noted if you look at?geom_map. At least by default, the id for each state infiftystater::fifty_statesis not calledstatebutid, and in your example picture it is calledstatename. - Calum You