rstats

A replacement for theme_blank()

October 2, 2012 | is.R()

ggplot2 has just hit 0.9.2, and with the change comes a new theme system. Previous versions of ggplot2 offered a theme_blank(), which was a stripped-down, essentially blank plotting canvas, but it is now deprecated. github user jrnold has produced a s... [Read more...]

Making random, equally-sized partitions

October 1, 2012 | is.R()

Sometimes, as with cross-validation, one needs to generate k partitions, each with an equal number of observations. There are probably an infinite number of ways this could be done in R, but the Gist below illustrates one way to do it in four lines, w... [Read more...]

Padding integers for use in filenames

September 29, 2012 | Corey Chivers

If you’ve ever written code that generates a whole whack of files, you may have came across the following problem when processing them. Using a naming convention wherein files are numbered will  gum up any ordering which is based on string sorting (ls, for example). What you end up ... [Read more...]

Optimal seriation for your matrices

September 28, 2012 | is.R()

In our previous post, we used a quick-and-dirty method for ordering the axes on our heatmap. It has been pointed out to me that There is a Package for That (which is my nominee for a new slogan for R — not that it needs a slogan). seriation offe... [Read more...]

Continuous dispersal on a discrete lattice

September 27, 2012 | Corey Chivers

Dispersal is a key process in many domains, and particularly in ecology. Individuals move in space, and this movement can be modelled as a random process following some kernel. The dispersal kernel is simply a probability distribution describing the distance travelled in a given time frame. Since space is continuous, ... [Read more...]

Simplest possible heatmap with ggplot2

September 27, 2012 | is.R()

Featuring the lovely “spectral” palette from Colorbrewer. This really just serves as a reminder of how to do four things I frequently want to do: Make a heatmap of some kind of matrix, often a square correlation matrix Reorder a factor vari... [Read more...]

Modifying select off-diagonal items in a matrix

September 25, 2012 | is.R()

This is something I have had the occasion to do, and never remember how, so this is legitimately a reminder to my future self of how to do things with off-diagonal elements of a matrix. Select rows and columns are easy: mat[1:10, ] or mat[, -c(5)], for... [Read more...]

Visually-weighted regression plots, with Zelig

September 25, 2012 | is.R()

As a follow-up to yesterday’s post on producing visually-weighted regression plots, here is some code which illustrates the production of similar plots, but using Zelig’s convenient modeling and simulation functions. This code was produced... [Read more...]

Simple visually-weighted regression plots

September 24, 2012 | is.R()

There has recently been a lot of discussion of so-called “visually-weighted regression” plots. Folk hero Hadley Wickham suggests that such plots would be easy to implement with ggplot2, and so I have attempted to prove him right. The approa... [Read more...]

Converting an R object to text, with dput()

September 20, 2012 | is.R()

We’ve already briefly covered making a reproducible example, but I thought I’d go a little more in-depth on the very helpful function dput(). Whenever I am having trouble applying an operation to some R object, and need help, but want to av... [Read more...]

Copulas and tail dependence, part 1

September 17, 2012 | arthur charpentier

As mentioned in the course last week Venter (2003) suggested nice functions to illustrate tail dependence (see also some slides used in Berlin a few years ago). Joe (1990)'s lambda Joe (1990) suggested a (strong) tail dependence index. For lower t... [Read more...]

Mapping Bike Accidents in R

September 14, 2012 | Corey Chivers

At last weekend’s Hack Ta Ville event here in Montreal, I joined up with some talented urban planners and web devs to realize Vélobstacles. The idea of the project is to crowd source information on cycling conditions around the city. As with any crowd sourcing project, we were ... [Read more...]

F1 2012 Mid-Season Review

August 30, 2012 | Tony Hirst

Rather belatedly, I got around to posting a series of posts summarising the Formula One season to date: F1 2012 Mid-Season Review – Grid/Classification Analysis: for example, how do the drivers’ grid and final classifications compare? F1 2012 Mid-Season Review – Pit Stops: for example, how does pit stop performance across the teams ... [Read more...]

Walmart Invasion

August 26, 2012 | Corey Chivers

As an invasion biologist, the process of spatial spread is at the heart of what I do. When I came across this dataset of Walmart store openings since 1962 I couldn’t help but see it as an invasion front which looks a lot like a biological invasion or (albeit slow) ... [Read more...]

An update on visualizing Bayesian updating

August 17, 2012 | Corey Chivers

A while ago I wrote this post with some R code to visualize the updating of a beta distribution as the outcome of Bernoulli trials are observed. The code provided a single plot of this process, with all the curves overlayed on top of one another. Then John Myles White (... [Read more...]
1 2 3 4 5 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)