R-alpha: missing arguments

Luke Tierney (luke@stat.umn.edu)
Thu, 13 Jun 1996 09:26:27 -0500 (CDT)


From: Luke Tierney <luke@stat.umn.edu>
Message-Id: <9606131426.AA07766@nokomis.stat.umn.edu>
Subject: R-alpha: missing arguments
To: r-testers@stat.math.ethz.ch
Date: Thu, 13 Jun 1996 09:26:27 -0500 (CDT)

There seems to be something a bit peculiar about the handling of
missing arguments in a few cases:

-------------------------------------------------------------------------------
R : Copyright (c) 1996, Robert Gentleman and Ross Ihaka
Version 0.9, (Released: June 7, 1996)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

> f<-function(x,y) c(missing(x),missing(y))
> f(1,2)
[1] FALSE FALSE
> f(1,)
[1] FALSE FALSE
> f(,2)
[1] TRUE TRUE
> f(,)
[1] TRUE TRUE
> g<-function(x=3,y=4)c(x,y)
> g(1,2)
[1] 1 2
> g(1,)
[[1]]
[1] 1

[[2]]
             # once I got something else here (see below)

> g(,2)
[1] 3 4
> g(,)
[1] 3 4
>
-------------------------------------------------------------------------------

The case g(1,) seems particularly weird -- in another run with a bit
more in between I got something even a bit more peculiar (see the ****
comment -- I included the full transcript to help reproduce this):

------------------------------------------------

R : Copyright (c) 1996, Robert Gentleman and Ross Ihaka
Version 0.9, (Released: June 7, 1996)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

Error in device("X11", as.character(c(display)), as.double(c(width, height))) :
unable to start device X11
> f<-function(x,y) c(missing(x),missing(y))
> f(1,2)
[1] FALSE FALSE
> f(1,)
[1] FALSE FALSE
> f(,2)
[1] TRUE TRUE
> f(,)
[1] TRUE TRUE
> g<-function(x,y)c(x,y)
> g(1,2)
[1] 1 2
> g(1,)
[[1]]
[1] 1

[[2]]


> g(,2)
Error: Argument "x" is missing, with no default
> g<-function(x=3,y=4)c(missing(x),missing(y))
> g(1,2)
[1] FALSE FALSE
> g(1,)
[1] FALSE FALSE
> g(,2)
[1] TRUE TRUE
> g<-function(x=3,y=4)c(x,y)
> g(1,2)
[1] 1 2
> g(1,)
[[1]]
[1] 1

[[2]]
[1] 2  # ******** this is the wierd result

> g(,2)
[1] 3 4
> g(,)
[1] 3 4
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-