Articles by is.R()

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

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

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

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

Side note…

September 18, 2012 | is.R()

MathJax allows you to customize how \( \LaTeX \) is displayed. Simply right click over the math you’d like to see to access the display menu. Under “math settings” you can see zoom trigger and factor options. Given how small the text ... [Read more...]

Embedding \(\LaTeX\) in Tumblr

September 18, 2012 | is.R()

The classic Pythagorean identity is:  \(sin^2(\theta) + cos^2(\theta) =1 \) The binomial formula which calculates the probability of obtaining k tails when flipping a coin n times, with a assumed probability p for each trial is: \( P(E)   = {n \choos... [Read more...]

Etymology

September 16, 2012 | is.R()

Chris and I started this blog as an outlet for the work we were already doing every day: writing code and trying to avoid forgetting how we wrote it. To that end, gist.github.com is an extremely useful resource, and this blog allows us to add a little ... [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)