On Thu, Nov 29, 2018 at 1:10 PM S Ellison <S.Ellison at lgcgroup.com> wrote:> > > > > 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"? > > A "missing argument" in R means that an argument with no default value was omitted from the call, and that is what I meant by "missing". > But that is not what is happening here. I was talking about "y=" apparently being treated as not present in the call, rather than the argument y being treated as a missing argument. > > In these examples, plot.default has a default value for y (NULL) so y can never be "missing" in the sense of the 'missing argument' error (compare what happens with plot(y=1:10), which reports x as 'missing'). > In the first example, y was (from the plot behaviour) taken as NULL - the default - so was not considered a missing argument. In the second, it was taken as 10:1 - again, non-missing, despite 10:1 being in the normal position for the (character) argument "type". > But neither call did anything at all with "y=". Instead, the behaviour is consistent with what would have happened if 'y=' were "not present at all" when counting position or named argument list, rather than if 'y' were an absent required argument. > It _looks_ as if the initial call parsing silently ignored the malformed expression "y=" before any argument matching - positional or by name - takes place.Yes, I think all of that is correct. But y _is_ missing in this sense:> debug(plot) > plot(1:10, y=)debugging in: plot(1:10, y = ) debug: UseMethod("plot") Browse[2]> missing(y) [1] TRUE though this does not explain the behavior since> plot( , , "l")debugging in: plot(, , "l") debug: UseMethod("plot") Browse[2]> missing(y) [1] TRUE --Ista> > But I'm thinking that it'll take an R-core guru to explain what's going on here, so I was going to wait and see. > > Steve Ellison > > > > ******************************************************************* > This email and any attachments are confidential. Any u...{{dropped:8}}
> Yes, I think all of that is correct. But y _is_ missing in this sense: > > plot(1:10, y=) > > ... > Browse[2]> missing(y)Although I said what I meant by 'missing' vs 'not present', it wasn't exactly what missing() means. My bad. missing() returns TRUE if an argument is not specified in the call _whether or not_ it has a default, hence the behaviour of missing(y) in debug(plot). But we can easily find out whether a default has been assigned: plot(1:10, y=, type=) Browse[2]> y NULL Browse[2]> type "p" ... which is consistent with silent omission of 'y=' and 'type=' Still waiting for a guru... Steve E ******************************************************************* This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmaster at lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
But the main point is where arguments are mixed together:> debugonce(plot.default) > plot(x=1:10, y=, 'l')... Browse[2]> missing(y) [1] FALSE Browse[2]> y [1] "l" Browse[2]> type [1] "p" I think that's what I fall over mostly: that named, empty arguments behave entirely different from omitting them (", ,") And I definitely agree we need a guru to explain it all to us ( Cheers, Emil Bode ?On 30/11/2018, 15:35, "S Ellison" <S.Ellison at LGCGroup.com> wrote: > Yes, I think all of that is correct. But y _is_ missing in this sense: > > plot(1:10, y=) > > ... > Browse[2]> missing(y) Although I said what I meant by 'missing' vs 'not present', it wasn't exactly what missing() means. My bad. missing() returns TRUE if an argument is not specified in the call _whether or not_ it has a default, hence the behaviour of missing(y) in debug(plot). But we can easily find out whether a default has been assigned: plot(1:10, y=, type=) Browse[2]> y NULL Browse[2]> type "p" ... which is consistent with silent omission of 'y=' and 'type=' Still waiting for a guru... Steve E ******************************************************************* This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmaster at lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK