Posts Tagged ‘ rstats ’

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

Read more »

Deploy Rook Apps: Part II

October 12, 2012
By

In Part I, I described how you can deploy your Rook applications with rApache. This post describes how you can do it with R itself. But before we get into that, I’d like to explain the off-again on-again relationship Rook has had with CRAN, R&#82...

Read more »

Using cairographics with ggsave()

October 12, 2012
By
Using cairographics with ggsave()

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
By
From holey polygons to convex hulls

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
By
Simple marimekko/mosaic plots

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 »

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

October 9, 2012
By
Conditional Colors and Shapes in plot() with ifelse()

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

Read more »

Functions for plotting and getting Greek in labels

October 8, 2012
By
Functions for plotting and getting Greek in labels

The problem: We often want to plot data and assign plot attributes based on characteristics of the data. For example, if we have a group of students with the following IQs, we might want to indicate who is an outlier in the statistical sense. I like...

Read more »

Calculating distances (across matrices)

October 5, 2012
By
Calculating distances (across matrices)

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 »

its the Gramma an punctuashun wot its’ about, Rgiht?

October 4, 2012
By
its the Gramma an punctuashun wot its’ about, Rgiht?

This is another of those confluence style posts, where a handful of things I’ve read in quick succession seem to phase lock in my mind: (brought to mind in part via @downes a week or so ago: How to Synch 32 Metronomes) The first was a post by Alan Levine on Making Text Work, which

Read more »

Log odds ratios and an indicator matrix from categorical data

October 4, 2012
By
Log odds ratios and an indicator matrix from categorical data

A long title, but there are a couple of handy things in this Gist. The first, and more obscure, is the conversion of a data.frame of categorical variables into a matrix of dummy/binary/indicator variables, one for each category of each original variab...

Read more »