I was looking for how to scrape tables from a website other than using python and R. I found an easy way to scrape data using Google spreadsheet as described in Tony’s blog. After randomly downloading some world economic data I wondered how to represent them using R or some other visualization tools.
This led me to learn rworldmap, which is a package for visualising global data, concentrating on data referenced by country codes or gridded at half degree resolution. The tricky part of this package is to join your data to the world map. You have to specify the name of column containing your country identiers (nameJoinColumn) and the type of code used (joinCode). If you only have country names rather than codes use joinCode=”NAME”, you can expect more mismatches because there is greater variation in what a single country may be named. Country codes could be obtained from here.
First, I tried to plot the World countries debt as a percentage of their GDP for the year 2011.
library(rworldmap)
countryData = read.table("your_data.txt",sep="\t",header=T)
#Join the data to the map. Make sure 'nameJoinColumn' has the ISO3 country codes
sPDF = joinCountryData2Map( countryData, joinCode = "ISO3", nameJoinColumn = "ISOV3",verbose=TRUE)
par(mai=c(0,0,0.2,0),xaxs="i",yaxs="i")
mapCountryData( sPDF, nameColumnToPlot="Percentage_of_GDP",colourPalette="heat",mapTitle='World Countries debt as a percentage of GDP for 2011')
You could also use this to analyze your data by region(I think it won’t be appropriate for my data set but I still tested it)
mapByRegion( countryData, nameDataColumn="Percentage_of_GDP", joinCode="ISO3", nameJoinColumn="ISOV3", regionType="Stern", FUN="mean", mapTitle='World Regions debt as a percentage of GDP for 2011')
If these plots don’t tell the story needed, The continuous data could be put into categories outside of the
rworldmap functions and then colors could be assigned and be plotted as a categorical data.
#creating a user defined colour palette
op = palette(c('green','yellow','orange','red'))
#find quartile breaks
cutVector = quantile(sPDF@data[["Percentage_of_GDP"]],na.rm=TRUE)
#classify the data to a factor
sPDF@data[["Debt_categories"]] = cut(sPDF@data[["Percentage_of_GDP"]], cutVector, include.lowest=TRUE )
#rename the categories
levels(sPDF@data[["Debt_categories"]]) = c('low', 'med', 'high', 'very high')
#mapping
mapCountryData(sPDF, nameColumnToPlot='Debt_categories', catMethod='categorical', mapTitle='World Countries debt as a percentage of GDP', colourPalette='palette', oceanCol='lightblue', missingCountryCol='white')
Data Source: Wikipedia and World Bank

I thought you might like to know that there is an R package for downloading World Bank data available on CRAN. It is called WDI and it works very well.