Blog Archives

Animated Plots with R

June 12, 2011
By
Animated Plots with R

Using ImageMagick it's pretty easy to make an animated gif from a set of plots. Essentially the way to do it is to save a plot for each frame of the animation and then convert them into a .gif. Here's a simple example that plots binomial density's for ...

Read more »

Rejection Sampling

June 9, 2011
By
Rejection Sampling

An interesting sampling method that was covered briefly in my Bayesian statistics course was rejection sampling. Since I have nothing better to do, I thought it would be fun to make an acceptance-rejection algorithm using R. FUN!The Rejection Sampling method is usually used to simulate data from an unknown distribution. To do this one samples...

Read more »

Accessing MySQL through R

May 5, 2011
By

Connecting to MySQL is made very easy with the RMySQL package. To connect to a MySQL database simply install the package and load the library.install.packages("RMySQL")library(RMySQL)Connecting to MySQL:Once the RMySQL library is installed create a dat...

Read more »

Hofstader’s Chaotic Sequence

April 30, 2011
By
Hofstader’s Chaotic Sequence

About a year ago I was reading Godel, Escher, Bach by Douglas Hofstadter. In a section on recursion he presents a sequence that he calls "A Chaotic Sequence" defined as:Q(n) = Q(n - Q(n - 1)) + Q(n - Q(n - 2)) for n > 2Q(1) = Q(2) =1It's sim...

Read more »

Plotting Maps with R

April 26, 2011
By
Plotting Maps with R

I stumbled upon this tutorial while not studying and I thought it would be fun to try and plot maps of the San Francisco Bay Area household income, education, population density, poverty, etc...To do this I needed a Shapefile for the Bay Area zip codes similar to the London borough file used in...

Read more »