# Let R fly: Visualizing Export Data using R

**nzprimarysectortrade » R related**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Having been using R for 5+ years, visiting www.r-bloggers.com daily, learning cool tricks from it and knowing cool UseRs from it, I finally decide to quit being an observer and start to be a contributor to this wonderful community. In this very first of my blog, I would like to demonstrate how to use a very cool R GUI — RAnalyticFlow and three useful R packages — rworldmap, gregmisc and TeachingDemos to visualize New Zealand primary export data (the data used in this post are freely and publicly available from www.stats.govt.nz).

RAnalyticFlow is a free GUI for R. It lets you to create flow charts of R codes. I find it really useful to break down big chunks of R codes into small manageable pieces. It also allows you to put non-essential codes (plots or checking data) out of essential ones. Below is an example

I am not going to details about this GUI but I do encourage you to download and have a play (runs on Mac, Windows and Linux). It is addictive that I must warn you though. A little downside is that it only supports 32-bit R. But the developers are approachable if you want a version that supports 64-bit.

My goal here is to plot two world maps that show

- what primary-sector-products have been exported to which countries for the year ended June 2011
- what is the change on last year

“rworldmap” package offers functionality to visualize data on a world map. “mapPies” is fairly flexible function that is suitable for the first job. Forming the data is pretty straightforward, which I will skip here. One thing that I like to point out is that “trim” function from “gregmisc” package is a useful function to eliminate spaces ahead and at the rear of strings (worth to keep in your pocket).

After having the map plotted, I like to have some barplots on the map to display top 10 markets for each product. “subplot” function from “TeachingDemos” package plots basic R graphs on an existing plot for a given position. For the background of these barplots, I used “rect” function. The final product rolls out like below

The second job is to show the change in export revenue on last year. “mapBars” from “rworldmap” function offers the functionality to do that, but it plots bars as stacked vertical or horizontal rectangular, which is different from conventional bar plots as we expect. Instead, I used “subplot” and “barplot” functions to consummate the job. The final product of the second job goes like

To conclude, I’d like to encourage you to give a try on RAnalyticFlow and consider using “rworldmap” package when you have worldwide data to visualize.

**leave a comment**for the author, please follow the link and comment on their blog:

**nzprimarysectortrade » R related**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.