Re: [Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread Ista Zahn
On Thu, Nov 29, 2018 at 1:10 PM S Ellison 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 > > > i

Re: [Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread S Ellison
> > 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

Re: [Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread Emil Bode
Well, I did mean it as "missing". To me, it felt just as natural as providing an empty index for subsetting (e.g. some.data.frame[,,drop=FALSE]) I can't think of a whole lot of other uses than subsetting, but I think this issue may be mostly important when you're not entirely sure what a call is

Re: [Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread Ista Zahn
On Thu, Nov 29, 2018 at 10:51 AM S Ellison 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 (

Re: [Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread S Ellison
> 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 match

[Rd] Small bug in the documentation of 'cut'

2018-11-29 Thread Göran Broström
The documentation of 'base::cut' says: ... the factor level labels are constructed as "(b1, b2]", "(b2, b3]" etc... In reality, the spaces after the commas are missing. I like the documented behavior better than the actual, though. > sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64

Re: [Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread Ista Zahn
On Thu, Nov 29, 2018 at 5:09 AM Emil Bode wrote: > > 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-

[Rd] Unexpected argument-matching when some are missing

2018-11-29 Thread Emil Bode
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

Re: [Rd] named arguments discouraged in `[.data.frame` and `[<-.data.frame`

2018-11-29 Thread Henrik Pärn
Thanks Emil for your thorough answer. It really clarified a lot to me. And revealed (even more of) my ignorance. >-Original Message- >From: Emil Bode >Sent: Thursday, November 29, 2018 10:48 AM >To: Henrik Pärn ; r-devel@r-project.org >Subject: Re: [Rd] named arguments discouraged in `[.

Re: [Rd] named arguments discouraged in `[.data.frame` and `[<-.data.frame`

2018-11-29 Thread Emil Bode
Well, the situation with `[.data.frame` (and [<-) is complicated by the fact that the data.frame-method is not a primitive, but the generic IS. I'm not sure about dispatch for primitive-generics, but I bet it's done on the first argument (as with S3). Which means `[`(j=1:2,d,i=1) has nothing to

Re: [Rd] named arguments discouraged in `[.data.frame` and `[<-.data.frame`

2018-11-29 Thread Henrik Pärn
Thanks Bill and Michael for taking the time to share your knowledge! As a further background to my question, here are two examples that I forgot to include in my original post (reminded by Michael's answer). I swapped the i and j arguments in `[.data.frame` and `[<-.data.frame`. With warnings,