From i@t@z@hn @ending from gm@il@com  Thu Nov 29 17:18:49 2018
From: i@t@z@hn @ending from gm@il@com (Ista Zahn)
Date: Thu, 29 Nov 2018 11:18:49 -0500
Subject: [Rd] Unexpected argument-matching when some are missing
In-Reply-To: <2ffdc3d61fcd4b098fa37a35a5cdffc9@GBDCVPEXC08.corp.lgc-group.com>
References: <AA681EA4-D0C7-4A2F-A719-01E510635C45@dans.knaw.nl>
 <2ffdc3d61fcd4b098fa37a35a5cdffc9@GBDCVPEXC08.corp.lgc-group.com>
Message-ID: <CA+vqiLFUYr5-OzJ7FmrjhT5owEiTJ2Q9x-O5mbv-tx=9c8iCaA@mail.gmail.com>

On Thu, Nov 29, 2018 at 10:51 AM S Ellison <S.Ellison at lgcgroup.com> wrote:
>
> > When trying out some variations with `[.data.frame` I noticed some (to me)
> > odd behaviour,
>
> Not just in 'myfun' ...
>
> plot(x=1:10, y=)
> plot(x=1:10, y=, 10:1)
>
> In both cases, 'y=' is ignored. In the first, the plot is for y=NULL (so not 'missing' y)
> In the second case, 10:1 is positionally matched to y despite the intervening 'missing' 'y='
>
> So it isn't just 'missing'; it's 'not there at all'

What exactly is the difference between "missing" and "not there at all"?

--Ista

>
> Steve E
>
> > -----Original Message-----
> > From: R-devel [mailto:r-devel-bounces at r-project.org] On Behalf Of Emil
> > Bode
> > Sent: 29 November 2018 10:09
> > To: r-devel at r-project.org
> > Subject: [Rd] Unexpected argument-matching when some are missing
> >
> > When trying out some variations with `[.data.frame` I noticed some (to me)
> > odd behaviour, which I found out has nothing to do with `[.data.frame`, but
> > rather with the way arguments are matched, when mixing named/unnamed
> > and missing/non-missing arguments. Consider the following example:
> >
> >
> >
> > myfun <- function(x,y,z) {
> >
> >   print(match.call())
> >
> >   cat('x=',if(missing(x)) 'missing' else x, '\n')
> >
> >   cat('y=',if(missing(y)) 'missing' else y, '\n')
> >
> >   cat('z=',if(missing(z)) 'missing' else z, '\n')
> >
> > }
> >
> > myfun(x=, y=, "z's value")
> >
> >
> >
> > gives:
> >
> >
> >
> > # myfun(x = "z's value")
> >
> > # x= z's value
> >
> > # y= missing
> >
> > # z= missing
> >
> >
> >
> > This seems very counterintuitive to me, I expect the arguments x and y to be
> > missing, and z to get ?z?s value?.
> >
> > When I call myfun(,y=,"z's value"), x is missing, and y gets ?z?s value?.
> >
> > Are my expectations wrong or is this a bug? And if my expectations are
> > wrong, where can I find more information on argument-matching?
> >
> > My gut-feeling says to call this a bug, but then I?m surprised no-one else has
> > encountered it before.
> >
> >
> >
> > And I don?t have multiple installations to work from, so could somebody else
> > confirm this (if it?s not my expectations that are wrong) for R-devel/other R-
> > versions/other platforms?
> >
> > My setup: R 3.5.1, MacOS 10.13.6, both Rstudio 1.1.453 and R --vanilla from
> > Bash
> >
> >
> >
> > Best regards,
> >
> > Emil Bode
>
>
>
> *******************************************************************
> This email and any attachments are confidential. Any u...{{dropped:11}}



[Rd] Unexpected argument-matching when some are missing
Ista Zahn