Allan Engelhardt
2010-Jul-01 17:24 UTC
[R] Documentation for library() and how to specify missing arguments
I can, after carefully reading about the returned values, see why library("MASS", "MASS", character.only=TRUE) has to chose between loading the package and displaying the help (I thought I had found a nice shortcut), but wouldn't the documentation be better if it said that the two are incompatible and that package= takes precedence over help=? As an aside, is there a way to explicitly specify a missing argument in a function call? For an example using the same function as before, library(, "MASS", character.only=TRUE) displays the help but can be a little hard on the programmer's eyes. However, library(NULL, "MASS", character.only=TRUE) library(NA, "MASS", character.only=TRUE) library({}, "MASS", character.only=TRUE) # signals error. doesn't do the same at all (I thought the first one would, based on the "whenever" in the documentation: "It is used whenever there is a need to indicate or specify that an object is absent."). Is there in the language a lexical x such that f(x, ...) is the same as f(, ...)? (Yes, I know about named arguments and I like them, I am just trying to learn syntax here.) Allan
David Winsemius
2010-Jul-01 17:40 UTC
[R] Documentation for library() and how to specify missing arguments
On Jul 1, 2010, at 1:24 PM, Allan Engelhardt wrote:> I can, after carefully reading about the returned values, see why > > library("MASS", "MASS", character.only=TRUE) > > has to chose between loading the package and displaying the help (I > thought I had found a nice shortcut), but wouldn't the documentation > be better if it said that the two are incompatible and that package= > takes precedence over help=? > > > As an aside, is there a way to explicitly specify a missing argument > in a function call? For an example using the same function as before, > > library(, "MASS", character.only=TRUE)I have always used: help(package=MASS) # does not need to be quoted My annoyance/whine is that various functions use "pkg", pkgs", or "package" as argument names. This is the only one I have successfully committed to memory.> > displays the help but can be a little hard on the programmer's > eyes. However, > > library(NULL, "MASS", character.only=TRUE) > library(NA, "MASS", character.only=TRUE) > library({}, "MASS", character.only=TRUE) # signals error. > > doesn't do the same at all (I thought the first one would, based on > the "whenever" in the documentation: "It is used whenever there is a > need to indicate or specify that an object is absent."). > > Is there in the language a lexical x such that f(x, ...) is the same > as f(, ...)? > > (Yes, I know about named arguments and I like them, I am just trying > to learn syntax here.) > > Allan-- David Winsemius, MD West Hartford, CT
Gabor Grothendieck
2010-Jul-01 23:28 UTC
[R] Documentation for library() and how to specify missing arguments
On Thu, Jul 1, 2010 at 1:24 PM, Allan Engelhardt <allane at cybaea.com> wrote:> > Is there in the language a lexical x such that f(x, ...) is the same as f(, > ...)? >Try this:> mx <- formals(identity)$x > missing(mx)[1] TRUE> sin(mx)Error in sin(mx) : 'mx' is missing