How do you create a state map 50 (and not just below 48)

How do you make a 50 state map in R?

It seems that all the examples created by people that were created by people belong to the bottom 48

+8
r maps heatmap
source share
4 answers

There are many ways you can do this. Personally, I believe that Google has the most attractive maps. I recommend ggmap , googleVis and / or RgoogleMaps .

For example:

 require(googleVis) G4 <- gvisGeoChart(CityPopularity, locationvar='City', colorvar='Popularity', options=list(region='US', height=350, displayMode='markers', colorAxis="{values:[200,400,600,800], colors:[\'red', \'pink\', \'orange',\'green']}") ) plot(G4) 

Produces the following:

enter image description here

Another approach, which will give you a more attractive result than maps , should follow the approach of this tutorial , which shows how to import custom maps from Inkscape (or, equivalently, Adobe Illustrator) to R for plotting.

You end up with something like this:

R and Inkscape

Here is the path to it with choroplethr and ggplot2 :

 library(choroplethr) library(ggplot2) library(devtools) install_github('arilamstein/choroplethrZip@v1.3.0') library(choroplethrZip) data(df_zip_demographics) df_zip_demographics$value = df_zip_demographics$percent_asian zip_map = ZipChoropleth$new(df_zip_demographics) zip_map$ggplot_polygon = geom_polygon(aes(fill = value), color = NA) zip_map$set_zoom_zip(state_zoom = NULL, county_zoom = NULL, msa_zoom = NULL, zip_zoom = NULL) zip_map$title = "50 State Map for StackOverflow" zip_map$legend = "Asians" zip_map$set_num_colors(4) choro = zip_map$render() choro data(df_pop_state) outline = StateChoropleth$new(df_pop_state) outline = outline$render_state_outline(tolower(state.name)) choro_with_outline = choro + outline choro_with_outline 

which gives you:

ggplot2

+14
source share

This R-bloggers link may be useful to you.

So you can see, you can get started on a map with 50 states using

 library(maps) map("world", c("USA", "hawaii"), xlim = c(-180, -65), ylim = c(19, 72)) 

enter image description here

Believe it or not, Hawaii is there. It is simply very small due to the margins.

+5
source share

Resurrection of the old thread, as it still does not have an accepted answer.

Check out @hrbrmstr albersusa package:

 devtools::install_github("hrbrmstr/albersusa") library(albersusa) plot(usa_composite(proj="laea")) 

which produces

enter image description here

and can do much more

 us <- usa_composite() us_map <- fortify(us, region="name") gg <- ggplot() gg <- gg + geom_map(data=us_map, map=us_map, aes(x=long, y=lat, map_id=id), color="#2b2b2b", size=0.1, fill=NA) gg <- gg + theme_map() gg + geom_map(data=us@data, map=us_map, aes(fill=pop_2014, map_id=name), color="white", size=0.1) + coord_proj(us_laea_proj) + scale_fill_viridis(name="2014 Populaton Estimates", labels=comma) + theme(legend.position="right") 

enter image description here

+5
source share

Perhaps you should consider using the state.vbm map in the maptools package, this includes all 50 states and makes more visible states more noticeable (great for coloring or adding graphs to each state, but the distances between sites will not be exact) .

Another option is to draw continuous 48 states, then in open areas add Alaska and Hawaii yourself. One option for this is to use the subplot function from the TeachingDemos package.

Here is an example of code using a couple of shapefiles provided by maptools:

 library(maptools) library(TeachingDemos) data(state.vbm) plot(state.vbm) yy <- readShapePoly(system.file("shapes/co37_d90.shp", package="maptools")[1]) zz <- readShapePoly(system.file("shapes/co51_d90.shp", package="maptools")[1]) xx <- readShapePoly(system.file("shapes/co45_d90.shp", package="maptools")[1]) plot(yy) par('usr') subplot( plot(zz), c(-84,-81), c(31,33) ) subplot( plot(xx), c(-81, -78), c(31,33) ) 

You just need to find the appropriate form files for the states.

+2
source share

All Articles