ggplot2 to PowerPoint in RStudio

R with ggplot2 is capable of producing visually appealing charts and is definitely more versatile than Excel for what concerns graphical representation of data. When it comes to presenting the results of an analysis though, PowerPoint is still the most widely used application, at least in the business environment.

This article shows a workflow to bring your ggplot2 charts to PowerPoint automatically, so you can build your analysis presentation directly from an R script within RStudio.

Continue Reading

Identifying outliers in R with ggplot2

One of the first steps when working with a fresh data set is to plot its values to identify patterns and outliers. When outliers appear, it is often useful to know which data point corresponds to them to check whether they are generated by data entry errors, data anomalies or other causes.

Unfortunately ggplot2 does not have an interactive mode to identify a point on a chart and one has to look for other solutions like GGobi (package rggobi) or iPlots.

However, if all is needed is to give a “name” to the outliers, it is possible to use ggplot labeling capabilities for the purpose. While labeling all points would usually produce a crowded and difficult to read plot, we can limit the labeling only to those points that respect certain conditions, namely our outliers.

Continue Reading

Pivot Tables in R with melt and cast

If you are making the transition from Excel to R and still can’t figure out how to quickly obtain pivot tables like Excel has, this article is for you!

Actually it is pretty easy to produce Pivot Tables in R. All you need is a package called reshape by Hadley Wickham (yes, the same prolific author of plyr and ggplot2) and some understanding of how reshape “thinks” and works.

Continue Reading

World population infographic with R

R is not just for statistical analysis and data mining, it can also be employed to prepare nice infographics. Here is a quick example of infographic with R.

With few lines of R code we can create, starting from commonly available data, an infographic showing the relative magnitude of the population for the different countries around the world, with the country name placed on the country centroid (like it would be on a map) and the font size proportional to the population size. Simple but impactful!

Continue Reading

Interactive map of world population with R

Recently I have been experimenting with R’s data visualization capabilities and I wanted to test how the maps plotted with rworldmap could be made interactive through the manipulate package, part of RStudio. Interactivity can add a lot to our understanding of complex data sets, where variations happens along multiple dimensions. To get inspired on the topic you can watch this great Ted Talk  by Hans Rosling: Stats that reshape your world-view.

Continue Reading