Publications by Matt Asher
R: more plotting fun, this time with the Poisson
Click on image for a larger version. Here is the code: Related To leave a comment for the author, please follow the link and comment on their blog: Statistics Blog » r. R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science j...
459 sym 2 img
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 aren’t stated in the proble...
3087 sym 8 img
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, so I don’t ...
1072 sym 2 img
R: directing output to file on the fly, output flushing
To start sending all output to a file, do this: Related to this I recently had to use: This forces your console to print out any buffered content. Doing this will cost time, but if you are running a very long script and wonder if it is still alive, you might do something like this: Related To leave a comment for the author, please follow the ...
687 sym
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 infograp...
2113 sym 2 img
R: choose file dialog box
Needed this one recently, it pops up a window to pick a file to be used by r, then reads the contents into myData: Related To leave a comment for the author, please follow the link and comment on their blog: Statistics Blog » r. R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Clic...
517 sym
Connecting R and Python
There are a few ways to do this, but the only one that worked for me was to use Rserve and rconnect. In R, do this: 1 2 3 install.packages("Rserve") library(Rserve) Rserve(debug = FALSE, port=6311, args=NULL) Then you can connect in Python very easily. Here is a test in Python: 1 2 rcmd = pyRserve.rconnect(host='localhost', port=6311) print(rcmd(...
589 sym R (175 sym/4 pcs) 2 tbl
R: Dueling normals
More playing around with R. To create the graph above, I sampled 100 times from two different normal distributions, then plotted the ratio of times that the first distribution beat the second one on the y-axis. The second distribution always had a mean of 0, the mean of first distribution went from 0 to 4, this is plotted on the x-axis. Here is m...
759 sym R (199 sym/2 pcs) 2 img 1 tbl
R: A random walk though OOP land.
If you are used to object oriented programing in a different language, the way R does things can seem a little strange and backwards. “proto” to the rescue. With this library you can simulate “normal” OOP. I found the examples for proto not so helpful, so to figure out how the package works I sent one lonely red ant on a drunken walk. Her...
771 sym R (925 sym/2 pcs) 1 tbl
How many tanks? MC testing the GTP
It’s 1943 and you work for the good guys. A handful of German tanks have been captured, and each one has a serial number. This is back when serial numbers were still presumed to come in serial, one right after the other. Given your collection of numbered tanks, and assuming that any existing tank was just as likely to be captured as any other, ...
3696 sym R (1043 sym/1 pcs) 22 img