Blog Archives

Faceting as a preferable alternative to 3-D

October 18, 2012
By

Sometimes, people want to plot things in three dimensions. Others have spoken more eloquently than I could on the potential problems with plotting multiple two-dimensional relationships in a two-dimensional medium with an artificial three-dimensional ...

The distribution of ideology in the U.S. House (with plyr)

October 17, 2012
By

This Gist has a couple of things going on, I’ll just list them: It downloads the entire history of U.S. House DW-NOMINATE scores from voteview.com It evaluates aggregate statistics, with members grouped by party and congress, with easy weighted ...

Flag space: a scatter plot of raster images

October 16, 2012
By

(Click for a bigger version) I’m not sure when plotting raster images in an R scatter plot will end up being useful. It’s not something I expect to need to do in my day-to-day research, and I think in general probably adds more complexity ...

Gale-Shapley Deferred Acceptance in R

October 15, 2012
By

In honor of today’s announcement of the Nobel Prize for Roth and Shapley, I found an illustration of the deferred acceptance algorithm from 1962 in R. Credit for the code goes to the blogger at Letters from London, and I’ve included a Gi...

Banking to n degrees

October 15, 2012
By

As often happens, I have learned of a technique just as it is being called into question. In this case, the technique is changing the aspect ratio of a line plot such that the typical slope of each segment is 45° (see), a rule of thumb which has bee...

How to choose the right *apply function

October 13, 2012
By

How to choose the right *apply function: This is an amazing stackoverflow answer to help you decide which of the many *apply functions (apply, lapply, sapply, vapply, mapply, rapply, tapply) is appropriate for the task at hand. I’m planning on doing...

Using cairographics with ggsave()

October 12, 2012
By

Whenever possible, I try to save R graphic output in a vector format, typically pdf(). I also like to use the handy ggsave() function to do so, as it streamlines the process, and makes it easy to be consistent across formats. However, at times it is n...

From holey polygons to convex hulls

October 11, 2012
By

I only rarely have the occasion to need the convex hull of a set of points, but I love chull(), so I’d like to share an example of how to use it. This Gist also offers a pretty straightforward application of the Split-Apply-Combine strategy (see...

Simple marimekko/mosaic plots

October 10, 2012
By

I don’t really care for the name “marimekko” or “mosaic,” but I do like this type of plot as a means of illustrating proportions in nested categorical data, or as an alternative to the parallel time series plots discussed...

Conditional Colors and Shapes in plot() with ifelse()

October 9, 2012
By

Here’s an example of how to color your plot shapes and pch using an ifelse() statement. Ifelse() is handy as it creates an easy way to branch a function. The syntax is: ifelse(logical.condition, option1, option2). Meaning, if the logical condi...

Recent popular posts

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update! Subscribe to R-bloggers to receive e-mails with the latest R posts.(You will not see this message again.)

Click here to close (This popup will not appear again)