Publications by is.R()

Image Manipulation in R, Part 1

26.11.2012

So, you know how to load PNG files, access their innards, and plot them as points in a scatter plot. But, is it possible to use R to do some of the awesome things you can do with Mathematica? Well, in this series of posts, I’ll introduce just a few of the things we can do with images in R — we can’t do everything that Mathematica does (at...

1608 sym 6 img

"Dominant" Color Palettes with k-means

27.11.2012

The idea of deriving color palettes from images has long been an interest of mine. There are places you can do this online, but it’s at least plausible that you might want to identify dominant colors programatically, for a large number of images. Charles Leifer shows one approach to the problem with python, and today’s Gist illustrates how...

1271 sym 12 img

Images as Voronoi tesselations

28.11.2012

This is probably the coolest-looking thing I’ve figured out how to do with raster images in R. Similar to (although not quite as impressive as) these images by Jeff Clark, I alter the simple k-means approach described in the previous post to cluster primarily in Cartesian space, rather than in color space. This produces, essentially, Voron...

1106 sym 10 img

Finding a bright object

30.11.2012

Finally, to return to the challenge I laid out in the first of this series on image manipulation in R: can we do anything as cool in R as can be done in Mathematica? Like, for example, this illustration of how to search images of the surface of Mars for bright anomalies? The answer is “approximately.” Today’s Gist shows how to take the im...

1030 sym 4 img

Using XML to grab tables from the web

01.12.2012

We’re going to try, this December, to bring you an “Advent CalendaR,” for each of the 24 days leading up to Christmas. Each day, our hope is to unwrap a useful R package to show you a useful or interesting function inside! Today’s Gist shows how to use the XML package to grab an HTML table, without needing too much work with regular expre...

864 sym 2 img

Rolling means (and other functions) with zoo

02.12.2012

The zoo package is designed for use with (potentially irregular) time series data. It is widely used for any number of applications, but among its most frequently useful functions are the roll* functions, such as rollmean, rollmedian, rollmax, rollapply, etc. Today’s Gist shows you how to use these rolling functions to summarize time series dat...

1026 sym 4 img

Scaling legislative roll call votes with wnominate

03.12.2012

We’ve used NOMINATE scaling data before here at is.R(), but today’s Gist shows, in just a few lines of code, how to download up-to-date roll call data and run those votes through Keith Poole (et. al.)’s DW-NOMINATE procedure. It’s really very straightforward — the tricky parts are getting the roll call object in the proper format (if i...

945 sym 4 img

Reading/Writing Stata (.dta) files with Foreign

04.12.2012

Oftentimes we find ourselves collaborating with others who might not use R or prefer to use Stata to clean and manage their data. Luckily, there is the foreign package that permits handling data of different types (SAS, SPSS, Stata, etc.) within the R environment. The documentation can be found here:  http://cran.r-project.org/web/packages/forei...

2419 sym 12 img

APSRtable: Getting Tables from R to \( \LaTeX \)

05.12.2012

Oftentimes you might be writing in LaTeX and trying to push your results from R into your .tex file. This, at times, can be very frustrating. Luckily, there’s apsrtable, an R package that automatically produces the LaTeX code for your  R model objects. The code below is relatively self-explanatory, and the package manual will help. To get the ...

1386 sym 8 img

Flexibly outlining a set of points with alphahull

06.12.2012

We’ve previously covered the convex hull here at is.R(), and in that post I admitted that I was somewhat hard-pressed to come up with a common use-case — at least for Political Science applications. Well, today’s Gist illustrates the use of something even cooler than the convex hull, in fact it’s the generalization of the convex hull: the...

1020 sym 4 img