Publications by Jason Bryer
Object Oriented Programming in R
As someone who was a Java programmer for many years learning R’s object oriented programming framework has been frustrating to say the least. I like the simplicity of S3 but find it limiting when you wish to write methods that change the underlying data elements. That is, printing, summarizing, and plotting work great because they generally do ...
1765 sym R (1397 sym/1 pcs)
Given a room with n people in it, what is the probability any two will have the same birthday?
Revisiting a fun puzzle I remember first encountering as an undergraduate. Nice example of creating a plot in R using ggplot2. I also plot the probability of someone in the room having the same birthday as you. ## See http://en.wikipedia.org/wiki/Birthday_problem for an explanation of the problemrequire(ggplot2)require(reshape) theme_update(pan...
691 sym R (599 sym/1 pcs) 2 img
makeR: An R Package for Managing Document Building and Versioning
If you are reading this vis-à-vis R-Bloggers, then you know how good R, LaTeX, and Sweave are for generating reports and/or conducting reproducible research. It has been particularly valuable for me in Institutional Research where there are many reports that I need to prepare on a regular basis (some monthly, some quarterly, some annually). Ho...
3132 sym
Setting Up and Customizing R
For the longest time I resisted customizing R for my particular environment. My philosophy has been that each R script for each separate analysis I do should be self contained such that I can rerun the script from top to bottom on any machine and get the same results. This being said, I have now encountered a situation where there are multiple re...
1549 sym R (4303 sym/2 pcs)
Graphic Parameters (symbols, line types, and colors) for ggplot2
Following up on John Mount’s post on remembering symbol parameters in ggplot2, I decided to give it a try and included symbols, line types, and colors (based upon Earl Glynn’s wonderful color chart). Code follows below. require(ggplot2) require(grid) theme_update(panel.background=theme_blank(), panel.grid.major=theme_blank(), pan...
785 sym R (2268 sym/5 pcs) 8 img
User Input using tcl/tk
I was inspired by Kay Cichini recent post on creating a a tcl/tk dialog box for users to enter variable values. I am going to have a use for this very soon so took some time to make it a bit more generic. What I wanted is a function that takes a vector (of variable names) of arbitrary length, create a dialog box for an input for each, and retu...
1482 sym R (923 sym/8 pcs) 12 img
Visualizing Missing Data
There are several graphics available for visualizing missing data including the VIM package. However, I wanted a plot specifically for looking at the nature of missingness across variables and a clustering variable of interest to support data preparation in multilevel propensity score models (see the multilevelPSA package). The following examples...
1377 sym R (385 sym/3 pcs) 2 img
Fun with coin flips
We all know that the odds of flipping an unbiased coin is 50% heads, 50% tails. But what happens if you do this a lot of times. Do you expect the same number of heads and tails? What if we took a cumulative sum where heads = +1 and tails = -1. What would that sum be? Here is a function that will do this n times and plot it. probPlot <- function(n...
1250 sym R (1252 sym/2 pcs) 6 img
Fifty Shades of Grey in R
My wife went out to her book group tonight and their book of the month was 50 Shades of Grey. Sadly, I could think of is that plotting 50 shades in R would be a neat exercise. require(ggplot2) grey50 <- data.frame( x = rep(1:10, 5), y = rep(1:5, each=10), c = unlist(lapply(seq(10,255,5), FUN=function(x) { rgb(x,x,x, max=255) })), t = unlist(l...
584 sym R (485 sym/1 pcs) 2 img
Using (R) Markdown, Jekyll, & GitHub for a Website
Introduction Markdown has been growing in popularity for writing documents on the web. With the introduction of R Markdown (see also Jeromy Anglim’s post on getting started with R Markdown) and knitr, R Markdown has simplified the publishing of R analysis on the web. I recently converted my website from WordPress to Jekyll. Jekyll is a “stati...
5060 sym R (4900 sym/9 pcs)