Customizable charts with R base graphics and Shiny

I’ve uploaded a new R Shiny web application. The app shows daily precipitation for different locations around Alaska as far back as 1950. Statisticians and useRs may find the app interesting because of its customization features for controlling the look and feel of the R base graphics used to produce a customizable chart. UseRs of the Shiny package may find the customized CSS of the app interesting as well. I went with a darker theme this time. And if you find historical Alaska daily precipitation interesting, there is of course that. The emphasis here is on customization. This app only begins to scratch the surface, but it represents a good first example of making various R base graphics plotting arguments, among other things, available to the useR via a Shiny app.

akDailyPrecipCustomCharts
Currently the app includes a variety of options: location selection, subsetting by year range, time series centering on a specific month depending on how you want to define/display a precipitation year, handling and display of missing data and setting monthly and annual missing data thresholds, whether to draw all of the marginal panel plots, color themes and gradients, and various options for rescaling relative circle size depending on the intra- and inter-annual variability in a location’s precipitation signal.

The latter can help make differences precipitation intensities stand out more or less and it is important to understand that this is all relative. It is common practice to let the size of points correspond monotonically to their values, using a log transformation of the data for example, just as it is to use no transformation at all. This is to help visually communicate an idea and draw attention to underlying patterns that may be harder to see on a linear scale. For those familiar with R, I allow for some recursive log transformations as well as some linear multipliers of plot arguments such as cex so that you have more control over the display on account of some locations having wildly different variability in historical daily precipitation intensities. What may look informative at one location may yield a less helpful plot for another location under the same graphical parameter settings.

Also, even with no transformations, circle size and color gradient are based on the data for the selected location, not across all locations. The latter would conveniently make relative intensity comparisons across plots of multiple locations possible. However, applying the scaling across datasets would wash out much of the color and size variation within datasets, making the graphics actually shown here less informative on an individual basis. When time permits, I would like to add a feature for plotting precipitation events for two selected places on one graph, where both datasets share a common color and size gradients for their data points. Lastly, the plots may take several seconds to load in the browser. Please be patient. I would like to speed up the code when I have some time by breaking much of the data manipulation code out of the final plotting command where it currently resides. This way, re-plotting can happen more quickly when changing aesthetic features as opposed to actually altering the selection of the underlying dataset or subset. Alas, there is not enough time in the day to deal with this yet…

This entry was posted by Matt Leonawicz.

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

%d bloggers like this: