Articles by Karl Broman

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

August 20, 2013 | Karl Broman

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 ... [Read more...]

Electronic lab notebook

August 20, 2013 | Karl Broman

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 ... [Read more...]

Read the source code

August 6, 2013 | Karl Broman

The other day, there was a bit of a twitter conversation about qqline in R. It made me think: how exactly is the line produced by qqline chosen? I seemed to recall that the line was through the first and third quartiles. An advantage of R is that you can ... [Read more...]

More on Chutes & Ladders

May 20, 2013 | Karl Broman

Matt Maenner asked about the sawtooth pattern in the figure in my last post on Chutes & Ladders. Damn you, Matt! I thought I was done with this. Don’t feed my obsession. My response was that if the game ends early, it’s even more likely that it’ll be ... [Read more...]

Chutes & ladders: How long is this going to take?

May 17, 2013 | Karl Broman

I was playing Chutes & Ladders with my four-year-old daughter yesterday, and I thought, “How long is this going to take?” I saw an interesting mathematical analysis of the game a few years ago, but it seems to be offline, though you can read it via the wayback machine. But that ... [Read more...]

Stack Exchange: Why I dropped out

May 13, 2013 | Karl Broman

Stack Exchange is a series of question-and-answer sites, including Stack Overflow for programming and Cross Validated for statistics. I was introduced to these sites at a short talk by Barry Rowlingson at the 2011 UseR! meeting, “Why R-help must die!“ These sites have a lot of advantages over R-help: The format ... [Read more...]

Tutorials on git/github and GNU make

May 10, 2013 | Karl Broman

If you’re not using version control, you should be. Learn git. If you’re not on github, you should be. That’s real open source. To help some colleagues get started with git and github, I wrote a minimal tutorial. There are lots of git and github resources available, ... [Read more...]

Beware of grep with a list

April 2, 2013 | Karl Broman

Another R tip: beware of as.character applied to a list. Really, beware of grep with a list: You might have thought that the result would be just 1, but grep expects a vector of character strings. If the input is not that, it uses as.character(). Since the result of ... [Read more...]

apply vs for

April 2, 2013 | Karl Broman

It’s widely understood that, in R programming, one should avoid for loops and always try to use apply-type functions. But this isn’t entirely true. It may have been true for Splus, back in the day: As I recall, that had to do with the entire environment from each ... [Read more...]

x[[c(5,3)]]

April 2, 2013 | Karl Broman

An R tip: Did you know that x[[c(5,3)]] is the same as x[[5]][[3]]? I should make more thorough use of this. In the help file for [[: [[ can be applied recursively to lists, so that if the single index i is a vector of length p, alist[[i]] is equivalent ... [Read more...]

Curved arrows in R

October 10, 2012 | Karl Broman

I briefly investigated how to draw curved arrows in R. Here’s a small piece of the figure that I ultimately created: A google search for “curved arrows in R” revealed three options: curvedarrow in the diagram package The internal function igraph.Arrows within the igraph package (mentioned by Gabor ... [Read more...]

Learning a new language

June 21, 2012 | Karl Broman

It had been a very long time since I’d tried to learn a new programming language. I started C in 1987, S in 1992, and Perl in 1997, but nothing really new in the subsequent 15 years. A friend now has me doing D, wanting to find time to learn ruby, and, most ... [Read more...]

A course in statistical programming

May 25, 2012 | Karl Broman

Graduate students in statistics often take (or at least have the opportunity to take) a statistical computing course, but often such courses are focused on methods (like numerical linear algebra, the EM algorithm, and MCMC) and not on actual coding. For example, here’s a course in “advanced statistical computing” ... [Read more...]

Should I be nice?

May 18, 2012 | Karl Broman

I got the following email. Subject: i have a question? Date: May 18, 2012 7:57:56 AM CDT how can i enter the data of QTL analysis. That was the whole thing. I presume that the writer wishes to use my R/qtl software. I could probably respond helpfully (for example, “See the sample ... [Read more...]

Halloween 2011 count

October 31, 2011 | Karl Broman

We don’t get many kids seeking candy at our house. I’m not sure if there just aren’t many kids in the neighborhood, or if it’s our location (next to the pond, with a big gap before the next house). I decided to keep track. As usual, ... [Read more...]

Ghastly R code

September 27, 2011 | Karl Broman

My R package, R/qtl, contains about 33k lines of R code (and 21k lines of C code). Some of it is quite good; some of it is terrible. Here’s another example of the terrible. I’ve long needed to revise the function scantwo, for performing a two-dimensional genome ... [Read more...]

Gamified

September 26, 2011 | Karl Broman

Barry Rowlingson gave an interesting talk at UseR 2011, “Why R-help must die!” He suggested the Q-and-A type sites Stack Overflow (on programming) and Cross Validated (on statistics), both part of Stack Exchange. An interesting feature of these sites is that, in addition to voting up and down on the questions ... [Read more...]

Quick labels within figures

August 26, 2011 | Karl Broman

One of the coolest R packages I heard about at the useR! Conference: Toby Dylan Hocking‘s directlabels package for putting labels directly next to the relevant curves or point clouds in a figure. I think I first learned about this idea from Andrew Gelman: that a separate legend requires ... [Read more...]
1 2 3

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)