[Rd] RFC: d/p/q/rgamma

Prof Brian Ripley ripley@stats.ox.ac.uk
Thu, 6 Sep 2001 08:59:10 +0100 (BST)

dgamma and friends in S are documented as

dgamma(x, shape, rate=1)
pgamma(q, shape, rate=1)
qgamma(p, shape, rate=1)
rgamma(n, shape, rate=1)

whereas R has

dgamma(x, shape, scale=1, log = FALSE)
pgamma(q, shape, scale=1, lower.tail = TRUE, log.p = FALSE)
qgamma(p, shape, scale=1, lower.tail = TRUE, log.p = FALSE)
rgamma(n, shape, scale=1)

Note the use of rate vs scale.  Indeed, as both S and R use `rate' for
exponential this seems somewhat strange, and the only such inconsistency I
can find.

I propose that we add a `rate' argument to d/p/q/rgamma as an alternative
to `scale', which is easily done.   The question is where?

I think we have a trap here for most users, who will happily copy

dgamma(x, 17, 0.3)

from their S-PLUS example sheet, and get the wrong answer. My preference
would be to have

dgamma(x, shape, rate, scale=1, log = FALSE)

etc.  That would break existing R code using positional matching.
Question: is there any?

The only really safe alternative is add `rate' as the last parameter.

Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch