Omegahat Statistical Computing

Ideas for statistical computing

Forgetting email attachments

Posted by omegahat on March 12, 2010

When I write email and say that I am attaching a document, I frequently send the mail and forget to attach the document. We’re all working too fast and off it goes. So I thought I’d write an extension for Thunderbird to check for the string attach. Just as I was about to do this, I decided to check if there was such an extension already. And sure enough there was – attachment reminder by Philipp Kewisch and Daniel Folkinshteyn. And sure enough it works nicely with my version of Thunderbird.


Posted in Uncategorized | Tagged: , | Leave a Comment »

RGraphics device and finding high-level graphical elements

Posted by omegahat on March 12, 2010

I just posted a new version (0.4-0) of the RGraphicsDevice package. This fills in a few details that enable lattice plots to appear fully. This package make its very easy to create new graphics devices for different formats. This has allowed me to experiment with devices for

  • Flash
  • KML
  • JavaScript canvas

and to create them with minimal fuss. The RFreetype package also allows us to compute metric info for fonts.

One of the things that I have been implementing with this RGraphicsDevice package in the last week is a device that keeps a list of all the calls to the primitives and their details. This is essentially the display list that is stored in a device, but we are doing this in R and able to put our own structure on the information for each call to the device. What’s the point? Well, it allows us to do something similar to what we did in the SVGAnnotation package. There we created R plots as SVG documents and then went back and post-processed the SVG to find the SVG elements that correspond to the graphical elements in the R plot, e.g. axes, labels, data points, legend, and so on. Given those SVG elements, we can add hyperlinks, interactive commands and even animation such as the gapminder-like display.

So how does this “component device” relate to this? Well, we can collect the graphical elements and then analyze and group them to identify the different elements of the R plots. Then we can use this to understand the order in which the elements were constructed and annotate or post-process code for Flash, JavaScript canvas, KML or SVG. This is the general approach to being able to map the low-level elements to the high-level graphical components of the plot and vice verse.

Posted in Graphics | Tagged: , , , | 1 Comment »

R plots and Google Earth in the browser

Posted by omegahat on March 12, 2010

In addition to playing with KML as a graphics device, I wrote up some notes that introduce how to put Google Earth into a Web browser and then use elements of the JavaScript API for Google Earth. This progresses to show how to add HTML form elements such as buttons and checkboxes to control the Google Earth display. And it ends by showing how to put an SVG plot created in R beside the Google Earth plugin and have that SVG plot be interactive. As the viewer moves the mouse over the time series in the R plot, the Google Earth display is rotated to show the corresponding US city.  The example is not necessarily very compelling, but the mechanism should allow us to do a lot more interesting things.

Posted in Graphics, Uncategorized | Tagged: , , , , | Leave a Comment »

RKMLDevice – R plots in KML

Posted by omegahat on March 12, 2010

One thing I have been tinkering with recently is the ability to create R plots as KML.  This is implemented in the RKMLDevice package on Omegahat. One creates a regular graphics device with the function kmlDevice() and issue regular R commands to generate the plot.  One can then display the resulting document in Google Earth (either stand-alone or the browser plugin) and the R plot will appear centered at the coordindates specified when creating the device.  This is not a PNG image, but the graphical elements in the plot are regular KML elements, i.e. Placemark elements.  This means they scale well. Also, they appear in the Folder for the plot and one can toggle their visibilities. There are some examples at

Posted in Graphics, Uncategorized | Tagged: , , , | Leave a Comment »

The Omegahat Stat. Computing blog

Posted by omegahat on July 9, 2007

For a long time I had it on my To-do list to install the relevant software on

which I could use to write about some of the things I was thinking about regarding statistical computing in general and also the specific things I was working on or trying to find the time to squeeze in. So here it finally is in the form of a hosted site. Why didn’t I think of that earlier 🙂

I posted something about the start of exploring the number of copies of objects made by R.

I am also interested in developing an extensible engine so that package developers can easily introduce new data structures that can be used directly in the R engine. An object-oriented language such as C++ is a useful approach, but involves a non-trivial amount of effort to move from our current source to that. We can use a “poor man’s” C++ via C and routine/function pointers. But one of the things that is useful, nay important, is to introduce some type specification into the R source code. See type specified routines.

An extensible system at the package level poses some issues for serialization/deserialization as converting a sequence of bytes to an instance of a potentially dynamically determined C/C++ data structure requires a factory of some sort which produces the instances.

Posted in Intro | Leave a Comment »