简体   繁体   中英

US heat map error

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

我发现我不得不将我的map_id = state重命名为我的表map_id = statename中的状态列的名称,并且它可以正常工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM