Monthly Archives: January 2010

Pivot tables in R

January 9, 2010
By
Pivot tables in R

A common data-munging operation is to compute cross tabulations of measurements by categories. SQL Server and Excel have a nice feature called pivot tables for this purpose. Here we'll figure out how to do pivot operations in R.Let's imagine an experim...

Read more »

Typos in Chapter 4

January 9, 2010
By
Typos in Chapter 4

Chapter 4 of “Introducing Monte Carlo Methods with R” has four typos (so far) in the exercises: – In Exercise 4.5, the should not be in bold fonts (!) – In Exercise 4.9, I commented too many lines when revising and thus the variance terms vanished. It should read– In Exercise 4.13, following the removal of

Read more »

sequential ideal point estimates

January 9, 2010
By
sequential ideal point estimates

Out of curiosity, I produced a “sequential” set of ideal point estimate for the (current) 111th U.S. Senate, plotting the results in the graph attached below (click on the thumbnail); as is conventional, red is Republican and blue is Democratic. The analysis uses all 373 non-unanimous roll calls in the 111th Senate thus far. Each

Read more »

Killing Yourself: An Addendum

January 9, 2010
By

In further support of the claim that a lot of deaths are partly self-induced, here’s a fascinating piece by Wired on the extraordinary rise in the percent of deaths among the young caused by their own poor decisions. It’s remarkable that, for the young, modern science has already made the world so safe that humanity,

Read more »

Because it’s Friday: Gravity Wells

January 8, 2010
By
Because it’s Friday: Gravity Wells

It's a little strange to see a web comic come up with such interesting visualizations, but xkcd has followed up on their movie timelines charts with this illustration of the gravitational attraction of the various bodies in the solar system. The gravitational force at the surface of the planet or moon determines how high you'd need to jump in...

Read more »

External pointers with Rcpp

January 8, 2010
By

pre{ border: 1px solid black ; font-size: x-small; }One of the new features of Rcpp is the XPtr class template, which lets you treat an R external pointer as a regular pointer. For more information on external pointers, see Writing R extensions...

Read more »

Example 7.21: Write a function to simulate categorical data

January 8, 2010
By
Example 7.21: Write a function to simulate categorical data

In example 7.20, we showed how to simulate categorical data. But we might anticipate needing to do that frequently. If a SAS function weren't built in and an equivalent R function not available in a package, we could build them from scratch.SASThe SAS code is particularly tortured, since we must parse the parameter string to extract the...

Read more »

Learning R via Python…or the other way around (with video!)

January 8, 2010
By

Last night I was one of five speakers at the NYC R Statistical Programming Meetup. The topic last night was dubbed the R Rosetta Stone, and the intent was to show how R as a language translated into several other analytical platforms and programming languages. Other speakers covered MATLAB, SAS, SQL/Postges and Clojure/Incanter—I

Read more »

R Tutorial Series: ANOVA Tables

January 8, 2010
By
R Tutorial Series: ANOVA Tables

The commonly applied analysis of variance procedure, or ANOVA, is a breeze to conduct in R. This tutorial will explore how R can be used to perform ANOVA to analyze a single regression model and to compare multiple models.Tutorial FilesBefore we begin,...

Read more »

Codecogs – Open-Source library of numerical components

January 8, 2010
By

The Codecogs website provides an Open-source library of functions for numerical analysis. One interesting component available on the website is the LaTeX equation editor which can be used to create graphics files of equations to include on webpages. The webpage describe this component as a A web-based LaTeX equation editor that generates graphical images and HTML

Read more »