Why does head() show 6 rows by default?

To answer a question like this, I first starting looking through the S books I have on hand (e.g. The New S Language). I don't see head() mentioned in the index, so that suggests it's a function introduced by R.

Since it's an R function, I can next search @winston's GitHub mirror of the R sources: https://github.com/wch/r-source, finding the source at https://github.com/wch/r-source/blob/af7f52f70101960861e5d995d3a4bec010bc89e6/src/library/utils/R/head.R

This includes a comment which suggest we should ask Patrick Burns:

### placed in the public domain 2002
### Patrick Burns patrick@burns-stat.com
###
### Adapted for negative arguments by Vincent Goulet
### <vincent.goulet@act.ulaval.ca>, 2006

But it's worth checking just to make sure it's always used 6. I click on history, and then find the first version: https://github.com/wch/r-source/commit/37271cdbdcd7e5d82c79bdb536ef305d93b644ad#diff-941bf47bf09f67538338535bd512d521 - so it has been six from the very beginning.

So next step, I'll email Patrick and see if he recollects...

38 Likes