for a school project I have to map some data on a geographical map in R. Therefore I\'ve got some data containing the zipcode and many other information (just no more informatio
Take a look at the R zipcode package; the website contains some examples. The package features geographical coordinates of all zipcodes, so it will be trivial to show them on a map.
Here is another pointer into the right direction: install the package "maps" and "zipcode". Load both of them into your environment:
library( zipcode ) ; library( maps )
Now plot the map of the US:
map( "usa" )
Load the zipcode data
data( "zipcode" )
Say, you have some zipcodes, for example 90001, 46243, 32920 and you want to show them on the map.
selected <- zipcode[ zipcode$zip %in% c( "90001", "46243", "32920" ), ]
The selected data frame contain information about the zipcodes. Plot them.
points( selected$longitude, selected$latitude, pch= 19, cex= 2 )
text( selected$longitude, selected$latitude, selected$zip, pos=3, cex= 2 )
Here is the result: