Publications by Karl Broman

Electronic lab notebook

20.08.2013

I was interested to read C. Titus Brown‘s recent post, “Is version control an electronic lab notebook?” I think version control is really important, and I think all computational scientists should have something equivalent to a lab notebook. But I think of version control as serving needs orthogonal to those served by a lab notebook. As Tit...

4153 sym 4 img

“[” and “[[” with the apply() functions

20.08.2013

Did you know you can use "[" and "[[" as function names for subsetting with calls to the apply-type functions? For example, suppose you have a bunch of identifier strings like "ZYY-43S-CWA3" and you want to pull off the bit before the first hyphen ("ZYY" in this case). (For code to create random IDs like that, see the end of this post.) Suppose ...

1173 sym R (401 sym/3 pcs) 4 img

knitr in a knutshell tutorial

06.02.2014

I spent a lot of time this week writing a short tutorial on knitr: knitr in a knutshell. This is my third little tutorial. (The previous ones were a git/github guide and a minimal make tutorial.) I’m pleased with these tutorials. In learning new computing skills, it can be hard to get started. My goal was to provide the initial motivation and ...

1369 sym 4 img

Googling errors

14.02.2014

@roguelynn tweeted the other day: If attendees of this weekend’s intro to python workshop leave with one thing, it’ll be to Google your error messages first and foremost. I had just talked about the technique in my Tools for Reproducible Research course, and I had a few recent examples. Gtk-WARNING **: cannot open display: I was logged into a...

1484 sym R (266 sym/2 pcs) 4 img

“[” with the apply() functions, revisited

29.04.2014

I’d mentioned in the fall that one could use "[" in the apply-type functions, like this: id <- c("ZYY-43S-CWA3", "6YU-F4B-VD2I") sapply(strsplit(id, "-"), "[", 2) I just realized that you can use this with matrices, too. If you have a list of matrices, you can pull out rows and columns with this technique. z <- list(matrix(1:10, nrow=2), matri...

684 sym R (169 sym/2 pcs) 4 img

Crayon colors in R

07.05.2014

Last night I was working on a talk on creating effective graphs. Mostly, I needed to update the colors, as there’d been some gaudy ones in its previous form (e.g., slide 22). I usually pick colors using the crayons in the Mac Color Picker. But that has just 40 crayons, and I wanted more choices. That led me to the list of Crayola crayon colors ...

1225 sym R (63 sym/1 pcs) 6 img

Two more points about crayon colors

08.05.2014

If you want to use crayon colors in R but you don’t want to rely on my R/broman package, you can just grab the code. Copy the relevant lines from the R/brocolors.R file: crayons = c("Almond"="#efdecd", "Antique Brass"="#cd9575", "Apricot"="#fdd9b5", ... "Yellow Green"="#c5e384", "Yello...

970 sym R (302 sym/2 pcs) 6 img

Further points on crayon colors

09.05.2014

I saw this great post on crayola crayon colors at the Learning R blog, reproducing a nice graph of the Crayola crayon colors over time. (Also see this even nicer version.) The Learning R post shows how to grab the crayon colors from the wikipedia page, “List of Crayola crayon colors,” directly in R. Here’s the code (after some slight modifi...

1412 sym R (250 sym/1 pcs) 6 img

hipsteR: re-educating people who learned R before it was cool

15.05.2014

This morning, I started a tutorial for folks whose knowledge of R is (like mine) stuck in 2001. Yesterday I started reading the Rcpp book, and on page 4 there’s an example using the R function replicate, which (a) I’d never heard before, and (b) is super useful. I mean, I often write code like this, for a bootstrap: x <- rnorm(2500) sapply(1:...

1118 sym R (180 sym/2 pcs) 4 img

2014 UseR conference, days 1-2

02.07.2014

I’m at UCLA for the UseR Conference. I attended once before, and I really enjoyed it. And I’m really enjoying this one. I’m learning a ton, and I find the talks very inspiring. In my comments below, I give short shrift to some speakers (largely by not having attended their talks), and I’m critical in some places about the conference org...

10481 sym 4 img