Blog Archives

Game of Life in R

May 5, 2010
By
Game of Life in R

Before I decided to learn R in a serious way, I thought about learning Flash/Actionscript instead. Most of my work involves evolutionary models that take place over time. I need visual representations of change. It’s certainly possible to represent change and tell an evolving story with a single plot (see for example Tufte’s favorite...

Read more »

R: directing output to file on the fly, output flushing

May 4, 2010
By

To start sending all output to a file, do this: sink("path/to/filename") # Direct all output to file print("Hi there") # Will be printed to file sink() # Turn off buffing to file Related to this I recently had to use: flush.console() This forces your console to print out any buffered content. Doing this will cost time, but if you are...

Read more »

First annual R plot replication prize

May 3, 2010
By
First annual R plot replication prize

$100 to the first person who can figure out how I created this plot and replicate it. Some hints: It was done in R. There is only one underlying probability distribution involved (one “rdist()“). Including the “plot” statement, I created this with 3 short lines of code. This is based on a random sampling of unstated size,...

Read more »

How many girls, how many boys?

April 30, 2010
By
How many girls, how many boys?

I found this interesting question over here at mathoverflow.net. Here’s the question: If you have a country where every family will continue to have children until they get a boy, then they will stop. What is the proportion of boys to girls in the country. First off, there are some assumptions you need to make that...

Read more »

R: more plotting fun, this time with the Poisson

April 21, 2010
By
R: more plotting fun, this time with the Poisson

Click on image for a larger version. Here is the code: par(bg="black") par(mar=c(0,0,0,0)) plot(sort(rpois(10000,100))/rpois(10000,100),frame.plot=F,pch=20,col="blue")

Read more »