Putting interest rates on US states map in R -
Putting interest rates on US states map in R -
how plot involvement rate bubbles of respective states in on map using r. in r have maps library , can draw states map. so.
library(maps) map("state", boundary = false, col="gray", add= true)
now if want add together bubble diameter involvement rate mean state on map of state. first find out capitols of states, find co-ordinates , utilize
points(latcapitol, loncapitol, col="blue",pch=19, cex=interest.rate )
for each state. there simpler way. perhaps library has required info state capitol co-ordinates. or should place points in middle of state , not on state capitols. plus how prepare eastern states density. there lot of little states in north east.
here solution
sample false dataset states mean involvement rate
state.mean.interest <- data.frame("state" = c("az", "id", "sc", "tx", "nj"), "mean.interest.rate" = c(10, 12, 14, 11, 9))
load maps , state dataset
library(maps) data(state)
create new dataframe merging 2 dataframes state dataset
state.location <- data.frame ("state" = state.abb, "longitude" = state.center$x, "latitude" = state.center$y)
merge 2 dataframes
state.mean.interest <- merge(state.mean.interest, state.location)
plot states map , involvement rate bubbles. can scale bubble however, want
map("state") points(state.mean.interest$longitude, state.mean.interest$latitude, pch = 19, col = "blue", cex = 2* state.mean.interest$mean.interest.rate/max(state.mean.interest$mean.interest.rate))
all done. should see state maps , bluish color bubbles on of states
r map
Comments
Post a Comment