World Map Visualizations Based on Data in R

I am working on a workshop for Business Analytics masters students. Part of the demos I intend to use are geographical visualizations. I am using rworldmap package to achieve these.

Let us say you have geographical data in a data.frame such as country, with country identifiers stored in “ip_iso2” column in ISO2 format and the variable of interest in “Supply” column. You plot this data as:


# Convert your data to a map that rworldmap can render country
country<- joinCountryData2Map(country, joinCode = "ISO2", nameJoinColumn = 'ip_iso2', verbose = T)
# Render the map
mapCountryData(country, nameColumnToPlot = "Supply")

Result would looke like this:

HEAT

A fancier example would be having a third grouping variable such as “Those” in a column.


# Initialize the map
mapDevice()
# Populate the map(, and change colors of land and oceans)
mapBubbles(dF=country, nameZSize="Supply", nameZColour="Those", colourPalette="rainbow", oceanCol="lightblue", landCol="wheat")

And this would be the result of this effort.

bubbles

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: