rstats

Adding a background to your ggplot

October 19, 2012 | is.R()

I really enjoy using the DW-NOMINATE data for examples, as I do here. Sometimes it’s useful to indicate regions in the background of a plot — perhaps two-dimensional regions of interest, perhaps one-dimensional periods in time. It’s... [Read more...]

Faceting as a preferable alternative to 3-D

October 18, 2012 | is.R()

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 ... [Read more...]

Flag space: a scatter plot of raster images

October 16, 2012 | is.R()

(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 ... [Read more...]

Gale-Shapley Deferred Acceptance in R

October 15, 2012 | is.R()

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... [Read more...]

Banking to n degrees

October 15, 2012 | is.R()

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... [Read more...]

Dark matter benchmarks: All over the map

October 14, 2012 | Corey Chivers

The three benchmark algorithms for predicting the location of dark matter halos are, for the most part, all over the map. Most of the test skies look something like this: There are, however, some skies with rather strong halo signals that get a decent amount of agreement: The Lenstool MLE ... [Read more...]

How to choose the right *apply function

October 13, 2012 | is.R()

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... [Read more...]

Using cairographics with ggsave()

October 12, 2012 | is.R()

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... [Read more...]

From holey polygons to convex hulls

October 11, 2012 | is.R()

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... [Read more...]

Simple marimekko/mosaic plots

October 10, 2012 | is.R()

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... [Read more...]

Calculating distances (across matrices)

October 5, 2012 | is.R()

This Gist is mostly for my future self, as a reminder of how to find distances between each row in two different matrices. To create a distance matrix from a single matrix, the function dist(), from the stats package is sufficient. There are times, ho... [Read more...]

Transforming a color scale

October 3, 2012 | is.R()

In developing plots, I often use color (or “colour” in ggplot2 parlance) to reflect values of a third, non-X/Y, variable. Depending on the distribution of this Z variable, however, the effective color range can be narrow, making it difficul... [Read more...]
1 2 3 4 11

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)