[R] error in duplicated() man page
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Thu May 9 19:15:02 CEST 2019
Thanks, Martin. I missed the duplication. My apology -- old age is
asserting it's presence.
Then my response is: I think the documentation is correct as written:
> a <- matrix(rep(1:3,2), nr=3)
> a
[,1] [,2]
[1,] 1 1
[2,] 2 2
[3,] 3 3
> duplicated(a)
[1] FALSE FALSE FALSE
> ## Note: Row major by default !
> duplicated(a, MAR = 2)
[1] FALSE TRUE
Again, apologies for my silly error.
Cheers,
Bert
On Thu, May 9, 2019 at 8:56 AM Martin Maechler <maechler using stat.math.ethz.ch>
wrote:
> >>>>> Bert Gunter
> >>>>> on Thu, 9 May 2019 08:46:15 -0700 writes:
>
> > Juan:
> > No, I think there may be a bug:
>
> >> duplicated(array(c(1,2,3,2,5,6),c(3,2)), MARGIN=1:2)
> > [,1] [,2]
> > [1,] FALSE TRUE
> > [2,] FALSE FALSE
> > [3,] FALSE FALSE
> > ## This is wrong
>
> > ## But if we first define the array...
> >> a <- array(c(1,2,3,4,5,6), c(3,2))
> >> duplicated(a, MARGIN = 1:2)
> > [,1] [,2]
> > [1,] FALSE FALSE
> > [2,] FALSE FALSE
> > [3,] FALSE FALSE
> > ## This is right
>
> Well, the two arrays are different:
> The first has a '2' instead of a '4'
> ((and this would not happen if you used 1:6 instead ..))
>
> > I'll wait a bit before filing a bug report so that any error I may be
> > making can be pointed out (note that my R version is NOT current, so
> I need
> > to update).
>
> >> sessionInfo()
> > R version 3.5.2 (2018-12-20)
> > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > Running under: macOS Mojave 10.14.4
>
> > Matrix products: default
> > BLAS:
> >
> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
> > LAPACK:
> >
> /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
>
> > locale:
> > [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> > attached base packages:
> > [1] stats graphics grDevices utils datasets methods base
>
> > loaded via a namespace (and not attached):
> > [1] compiler_3.5.2 tools_3.5.2
>
> > Bert Gunter
>
> > "The trouble with having an open mind is that people keep coming
> along and
> > sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> > On Thu, May 9, 2019 at 8:10 AM Juan Gomez <juangomezduaso using gmail.com>
> wrote:
>
> >> I think there is an error in duplicated() help page when it states
> that:
> >> "The array method calculates for each element of the sub-array
> >> specified by MARGIN if the remaining dimensions are identical to
> those
> >> for an earlier (or later, when fromLast = TRUE) element (in
> row-major
> >> order). "
> >> Instead of:
> >> "... (in column-major order)"
> >>
> >> For instance:
> >> duplicated(array(c(1,2,3,2,5,6),c(3,2)), MARGIN=1:2)
> >> [,1] [,2]
> >> [1,] FALSE TRUE
> >> [2,] FALSE FALSE
> >> [3,] FALSE FALSE
> >> >
> >>
> >> ______________________________________________
> >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
>
> > [[alternative HTML version deleted]]
>
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list