Question: How do you graph a map in R when your dataset has abbreviations for the state instead of the state name? For example I have
How do you graph a map in R when your dataset has abbreviations for the state instead of the state name? For example I have "AL" for "Alabama"... below is my coded so far but the dataset I am trying to merge with has the state name instead of the abbreviations...so the data will not megre...is there a dataset I can merge with that has the initial instead?
library(maps) library(mapdata) library(ggplot2) library(mapproj)
states_map = map_data("state")
ggplot(states_map, aes(x=long, y=lat, group=group)) + geom_polygon(fill="white", color="black")
FoodSrvcdata = read.table("FoodSrvcByCounty.txt", header=T, sep="\t")
head(FoodSrvcdata)
FoodSrvc_map = merge(states_map, FoodSrvcdata, by.x="Region", by.y="state") head(FoodSrvc_map) head(states_map)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
