I was right: They take the 25th and 75th percentiles of the data and of the theoretical distribution, calculate the slope and y-intercept of the line that goes through those two points, and use abline to draw the line.

Open source means the source is open, so why not take the time to look at it?

Sometimes typing the name of the function doesn’t tell you much:

# qqnorm
function (y, ...)
UseMethod("qqnorm")

In such cases, you could try typing, for example, qqnorm.default.

Still, the comments (if there were any) get stripped off, and for long functions, it’s not pretty. So I like to keep a copy of the source code (for example, R-3.0.1.tar.gz; extract it with tar xzf R-3.0.1.tar.gz). I use grep to find the relevant files.

For example,

grep -r 'qqline' R-3.0.1/src/

shows that I should look for qqline in

R-3.0.1/src/library/stats/R/qqnorm.R

For something like cor, you might want to do:

grep -r 'cor <-' R-3.0.1/src

Or maybe:

grep -r 'cor <-' R-3.0.1/src/library/stats/R

But for cor, you probably also want to look at the C code, which is in