>>>>> Bert Gunter
>>>>> on Sun, 6 Dec 2020 08:23:44 -0800 writes:
> All: I did not want to bother R folks for an R Bugzilla
> account, so I'll just note what appears to be a
> documentation bug here
> In R version 4.0.3, ?anyDuplicated says: "anyDuplicated(.)
> is a ?generalized? more efficient shortcut for
> any(duplicated(.)).
IIRC, I wrote that text there ..
> However, anyDuplicated returns an integer and
> any(duplicated) -- that is any() -- returns a logical. I
> was bitten by this by a function expecting a logical from
> anyDuplicated.
well, I was very aware / conscious of that and here's why I even
more liked the term "generalized" :
I'd argue that in S and hence R,
{0,1} are "almost the same" as {FALSE,TRUE},
(they are internally coded as integer 0, 1)
and e.g.
> identical(FALSE:TRUE, 0:1)
[1] TRUE>
> I realize that there are scare quotes around
> "generalized", which would indicate that anyDuplicated and
> any(duplicated(.)) aren't identical. However, I believe
> that the line above (especially 'shortcut') leads one to
> expect that both return a logical. A simple addition such
> as: "Note, however, that any() returns a logical and
> anyDuplicated's returns an integer' would avoid the
> confusion.
anyDuplicated() is mostly useful for if(.) or while(.)
and for these, it *is* a shortcut.
> Best to all, Bert
I really think help pages should be allowed to use expressive
language at times.. notably in the section 'Description'.
There's the 'Value:' section which one should *really* read as
well where it clearly says that anyDuplicated returns the index
in case there are duplicates.
To such a bug report I'm pretty strongly replying
"Works as documented"
Martin