haotu : an open lab notebook

2013/12/09

Make Global Maps in R

Filed under: Uncategorized — Tags: , , , , — S @ 09:44

There is a nice R package for plotting global maps. The package uses UN and ISO3 ids.

rworldmap

The article and tutorial is here: http://journal.r-project.org/archive/2011-1/RJournal_2011-1_South.pdf

library(rworldmap)

x<-data.frame(country=c("USA","CAN","MEX"),dat=c(100,50,0))

#joins the data to a global map
sPDF <- joinCountryData2Map( x , joinCode = "ISO3" , nameJoinColumn = "country")
#plots the map
mapCountryData(sPDF,nameColumnToPlot="dat",mapTitle="North America Example")

Here is an example of an image I created with this package on FAO plant production data

2013/12/03

R print to console in for loop or function

Filed under: R — S @ 03:53
for(i in 1:3)
{
  print(i)
  flush.console()
}

Create a free website or blog at WordPress.com.