Re: [R] Documentation for library() and how to specify missing arguments

2010-07-02 Thread Gabor Grothendieck
On Fri, Jul 2, 2010 at 9:27 AM, Jeffrey J. Hallman  wrote:
> Gabor Grothendieck  writes:
>> Try this:
>>
>>> mx <- formals(identity)$x
>>> missing(mx)
>> [1] TRUE
>>> sin(mx)
>> Error in sin(mx) : 'mx' is missing
>
> Neat. There's no way to look at 'mx' because calling any function
> with it as an argument gives that same error message, including the auto
> print function. What exactly is 'mx' here?

You can't look at mx directly but you can look look at the expression
that generates it to see that its a component of a pairlist with class
"name" and type "symbol" :

> class(formals(identity))
[1] "pairlist"
> class(formals(identity)$x)
[1] "name"
> typeof(formals(identity)$x)
[1] "symbol"

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Documentation for library() and how to specify missing arguments

2010-07-02 Thread Jeffrey J. Hallman
Gabor Grothendieck  writes:
> Try this:
>
>> mx <- formals(identity)$x
>> missing(mx)
> [1] TRUE
>> sin(mx)
> Error in sin(mx) : 'mx' is missing

Neat. There's no way to look at 'mx' because calling any function
with it as an argument gives that same error message, including the auto
print function. What exactly is 'mx' here?

-- 
Jeff

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Documentation for library() and how to specify missing arguments

2010-07-01 Thread Gabor Grothendieck
On Thu, Jul 1, 2010 at 1:24 PM, Allan Engelhardt  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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Documentation for library() and how to specify missing arguments

2010-07-01 Thread David Winsemius


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Documentation for library() and how to specify missing arguments

2010-07-01 Thread Allan Engelhardt

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.