Articles by is.R()

Plotting letters as shapes in ggplot2

November 5, 2012 | is.R()

This post is a little more esoteric than most, but I found myself needing to solve this problem, so I’m just passing the solution on to you. The plot above shows the distribution of DW-NOMINATE scores for the 18th Congress, with party indicated ... [Read more...]

GGtutorial: Day 4 – More Colors

November 1, 2012 | is.R()

So far we’ve covered Melting and Casting data using the reshape() package and today we’re going to look at different ways of coloring and selecting palettes for plots. For these plots, we’re going to use the built in diamonds data... [Read more...]

GGtutorial: Day 3 – Introduction to Colors

October 31, 2012 | is.R()

So, where does ggplot get its colors? If you’ve ever asked ggplot to color on the basis of a factor, you might have beeen surprised by the default color choices.  The fact is, ggplot colors factors on the basis of finding evenly spaced colors a... [Read more...]

Plotting correlation ellipses

October 26, 2012 | is.R()

This is an oldie but a goodie. There are a lot of ways to plot multiple bivariate relationships, but this is one of my favorites, courtesy of the R Graph Gallery. https://gist.github.com/819111 [Read more...]

Congressional ideology by state

October 25, 2012 | is.R()

In a recent post, I illustrated how to add a background geom to your ggplot. While that code worked, and the plot looked fine, it was pointed out to me that I was missing an important aspect of plot layering with ggplot2. Namely, it is not, as I previ... [Read more...]

Plotting the debate "Winner"

October 24, 2012 | is.R()

As a Political Scientist, it could not be more gauche to talk about the Presidential debate in terms of a winner and a loser, but the occasion provides the opportunity to show how to do (at least) three really useful things: Directly load price and v... [Read more...]

Benchmarking matrix creation

October 23, 2012 | is.R()

Sometimes it is useful to take a vector, or one column/row of a matrix, and build a new matrix of identical copies of that vector. There are lots of different ways to do this, but I just discovered a new, and very straightforward way to do this with m... [Read more...]

Distribution of colors by flag

October 22, 2012 | is.R()

A story: We showed you how to use R to assess flag similarity and make a scatter plot of raster images. Dr. Wickham referred us to the set of 2400 flag icons made available by GoSquared, and then (probably jokingly) challenged us to replicate the cool... [Read more...]

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...]

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...]
1 2 3 4

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)