New matrix function

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

New matrix function

MorganMorgan
Hi All,

I was looking for a function to find a small matrix inside a larger matrix
in R similar to the one described in the following link:

https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix

I couldn't find anything.

The above function can be seen as a "generalisation" of the "which"
function as well as the function described in the following post:

https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/

Would be possible to add such a function to base R?

I am happy to work with someone from the R core team (if you wish) and
suggest an implementation in C.

Thank you
Best regards,
Morgan

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Duncan Murdoch-2
On 11/10/2019 6:44 a.m., Morgan Morgan wrote:

> Hi All,
>
> I was looking for a function to find a small matrix inside a larger matrix
> in R similar to the one described in the following link:
>
> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
>
> I couldn't find anything.
>
> The above function can be seen as a "generalisation" of the "which"
> function as well as the function described in the following post:
>
> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
>
> Would be possible to add such a function to base R?
>
> I am happy to work with someone from the R core team (if you wish) and
> suggest an implementation in C.

That seems like it would sometimes be a useful function, and maybe
someone will point out a package that already contains it.  But if not,
why would it belong in base R?

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Spencer Graves-3


On 2019-10-11 04:45, Duncan Murdoch wrote:

> On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
>> Hi All,
>>
>> I was looking for a function to find a small matrix inside a larger
>> matrix
>> in R similar to the one described in the following link:
>>
>> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix 
>>
>>
>> I couldn't find anything.
>>
>> The above function can be seen as a "generalisation" of the "which"
>> function as well as the function described in the following post:
>>
>> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/ 
>>
>>
>> Would be possible to add such a function to base R?
>>
>> I am happy to work with someone from the R core team (if you wish) and
>> suggest an implementation in C.
>
> That seems like it would sometimes be a useful function, and maybe
> someone will point out a package that already contains it.  But if
> not, why would it belong in base R?


       The natural thing could be to add it to another existing package.


       A list of different search tools appear in the Wikiversity
article on "Searching R packages".[1]  I especially like the "sos"
package, which includes a vignette, [2] but I also use RDocumentation
and occasionally Rseek.  Google Advanced Search[3] is also very good; 
I've used that for other things, but not searching for R packages.


       I've had modest luck suggesting additions to other packages if I
write the function and documentation with good examples that tend to
ensure quality.  Some maintainers reject my suggestions;  other have
accepted them.


       Spencer Graves


[1]
https://en.wikiversity.org/wiki/Searching_R_Packages


[2] Caveat:  I wrote both that Wikiversity article and the "sos"
package, so I'm biased.


[3]
https://www.google.com/advanced_search

>
> Duncan Murdoch
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

MorganMorgan
In reply to this post by Duncan Murdoch-2
On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <[hidden email]> wrote:

> On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
> > Hi All,
> >
> > I was looking for a function to find a small matrix inside a larger
> matrix
> > in R similar to the one described in the following link:
> >
> >
> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
> >
> > I couldn't find anything.
> >
> > The above function can be seen as a "generalisation" of the "which"
> > function as well as the function described in the following post:
> >
> >
> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
> >
> > Would be possible to add such a function to base R?
> >
> > I am happy to work with someone from the R core team (if you wish) and
> > suggest an implementation in C.
>
> That seems like it would sometimes be a useful function, and maybe
> someone will point out a package that already contains it.  But if not,
> why would it belong in base R?
>

If someone already implemented it, that would great indeed. I think it is a
very general and basic function, hence base R could be a good place for it?

But this is probably not a good reason; maybe someone from the R core team
can shed some light on how they decide whether or not to include a function
in base R?


> Duncan Murdoch
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Wang Jiefei
Hi Morgan,

I think there is a discussion on how developers include a function in base
R in another thread:

https://stat.ethz.ch/pipermail/r-devel/2019-October/078551.html


Best,
Jiefei

On Fri, Oct 11, 2019 at 8:19 AM Morgan Morgan <[hidden email]>
wrote:

> On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <[hidden email]>
> wrote:
>
> > On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
> > > Hi All,
> > >
> > > I was looking for a function to find a small matrix inside a larger
> > matrix
> > > in R similar to the one described in the following link:
> > >
> > >
> >
> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
> > >
> > > I couldn't find anything.
> > >
> > > The above function can be seen as a "generalisation" of the "which"
> > > function as well as the function described in the following post:
> > >
> > >
> >
> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
> > >
> > > Would be possible to add such a function to base R?
> > >
> > > I am happy to work with someone from the R core team (if you wish) and
> > > suggest an implementation in C.
> >
> > That seems like it would sometimes be a useful function, and maybe
> > someone will point out a package that already contains it.  But if not,
> > why would it belong in base R?
> >
>
> If someone already implemented it, that would great indeed. I think it is a
> very general and basic function, hence base R could be a good place for it?
>
> But this is probably not a good reason; maybe someone from the R core team
> can shed some light on how they decide whether or not to include a function
> in base R?
>
>
> > Duncan Murdoch
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

R devel mailing list
In reply to this post by MorganMorgan
Thanks for this interesting suggestion, Morgan. While there is no strict
criteria for base R inclusion, one criterion relevant in this case is that
the usefulness of a feature be proven in the package space first.

Michael


On Fri, Oct 11, 2019 at 5:19 AM Morgan Morgan <[hidden email]>
wrote:

> On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <[hidden email]>
> wrote:
>
> > On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
> > > Hi All,
> > >
> > > I was looking for a function to find a small matrix inside a larger
> > matrix
> > > in R similar to the one described in the following link:
> > >
> > >
> >
> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
> > >
> > > I couldn't find anything.
> > >
> > > The above function can be seen as a "generalisation" of the "which"
> > > function as well as the function described in the following post:
> > >
> > >
> >
> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
> > >
> > > Would be possible to add such a function to base R?
> > >
> > > I am happy to work with someone from the R core team (if you wish) and
> > > suggest an implementation in C.
> >
> > That seems like it would sometimes be a useful function, and maybe
> > someone will point out a package that already contains it.  But if not,
> > why would it belong in base R?
> >
>
> If someone already implemented it, that would great indeed. I think it is a
> very general and basic function, hence base R could be a good place for it?
>
> But this is probably not a good reason; maybe someone from the R core team
> can shed some light on how they decide whether or not to include a function
> in base R?
>
>
> > Duncan Murdoch
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


--
Michael Lawrence
Scientist, Bioinformatics and Computational Biology
Genentech, A Member of the Roche Group
Office +1 (650) 225-7760
[hidden email]

Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

MorganMorgan
How do you prove usefulness of a feature?
Do you have an example of a feature that has been added after proving to be
useful in the package space first?

Thank you,
Morgan

On Fri, 11 Oct 2019 13:53 Michael Lawrence, <[hidden email]>
wrote:

> Thanks for this interesting suggestion, Morgan. While there is no strict
> criteria for base R inclusion, one criterion relevant in this case is that
> the usefulness of a feature be proven in the package space first.
>
> Michael
>
>
> On Fri, Oct 11, 2019 at 5:19 AM Morgan Morgan <[hidden email]>
> wrote:
>
>> On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <[hidden email]>
>> wrote:
>>
>> > On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
>> > > Hi All,
>> > >
>> > > I was looking for a function to find a small matrix inside a larger
>> > matrix
>> > > in R similar to the one described in the following link:
>> > >
>> > >
>> >
>> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
>> > >
>> > > I couldn't find anything.
>> > >
>> > > The above function can be seen as a "generalisation" of the "which"
>> > > function as well as the function described in the following post:
>> > >
>> > >
>> >
>> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
>> > >
>> > > Would be possible to add such a function to base R?
>> > >
>> > > I am happy to work with someone from the R core team (if you wish) and
>> > > suggest an implementation in C.
>> >
>> > That seems like it would sometimes be a useful function, and maybe
>> > someone will point out a package that already contains it.  But if not,
>> > why would it belong in base R?
>> >
>>
>> If someone already implemented it, that would great indeed. I think it is
>> a
>> very general and basic function, hence base R could be a good place for
>> it?
>>
>> But this is probably not a good reason; maybe someone from the R core team
>> can shed some light on how they decide whether or not to include a
>> function
>> in base R?
>>
>>
>> > Duncan Murdoch
>> >
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>
> --
> Michael Lawrence
> Scientist, Bioinformatics and Computational Biology
> Genentech, A Member of the Roche Group
> Office +1 (650) 225-7760
> [hidden email]
>
> Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Joris FA Meys
On Fri, Oct 11, 2019 at 3:55 PM Morgan Morgan <[hidden email]>
wrote:

> How do you prove usefulness of a feature?
> Do you have an example of a feature that has been added after proving to be
> useful in the package space first?
>
> Thank you,
> Morgan
>

The parallel package (a base package like utils, stats, ...) was added as a
drop-in replacement of the packages snow and multicore for parallel
computing. That's one example, but sure there's more.

Kind regards
Joris

--
Joris Meys
Statistical consultant

Department of Data Analysis and Mathematical Modelling
Ghent University
Coupure Links 653, B-9000 Gent (Belgium)
<https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>

-----------
Biowiskundedagen 2018-2019
http://www.biowiskundedagen.ugent.be/

-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Avraham Adler
In reply to this post by MorganMorgan
It’s rather difficult. For example, the base R Kendall tau is written with
the naive O(n^2). The much faster O(n log n) implementation was programmed
and is in the pcaPP package. When I say much faster, I mean that my
implementation in Excel VBA was faster than R for 10,000 or so pairs.
R-Core decided not to implement that code, and instead made a note about
the faster implementation living in pcaPP in the help for “cor”. See [1]
for the 2012 discussion. My point is it’s really really difficult to get
something in Base R. Develop it well, put it in a package, and you have
basically the same result.

Avi

[1] https://stat.ethz.ch/pipermail/r-devel/2012-June/064351.html

On Fri, Oct 11, 2019 at 9:55 AM Morgan Morgan <[hidden email]>
wrote:

> How do you prove usefulness of a feature?
> Do you have an example of a feature that has been added after proving to be
> useful in the package space first?
>
> Thank you,
> Morgan
>
> On Fri, 11 Oct 2019 13:53 Michael Lawrence, <[hidden email]>
> wrote:
>
> > Thanks for this interesting suggestion, Morgan. While there is no strict
> > criteria for base R inclusion, one criterion relevant in this case is
> that
> > the usefulness of a feature be proven in the package space first.
> >
> > Michael
> >
> >
> > On Fri, Oct 11, 2019 at 5:19 AM Morgan Morgan <[hidden email]
> >
> > wrote:
> >
> >> On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <[hidden email]>
> >> wrote:
> >>
> >> > On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
> >> > > Hi All,
> >> > >
> >> > > I was looking for a function to find a small matrix inside a larger
> >> > matrix
> >> > > in R similar to the one described in the following link:
> >> > >
> >> > >
> >> >
> >>
> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
> >> > >
> >> > > I couldn't find anything.
> >> > >
> >> > > The above function can be seen as a "generalisation" of the "which"
> >> > > function as well as the function described in the following post:
> >> > >
> >> > >
> >> >
> >>
> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
> >> > >
> >> > > Would be possible to add such a function to base R?
> >> > >
> >> > > I am happy to work with someone from the R core team (if you wish)
> and
> >> > > suggest an implementation in C.
> >> >
> >> > That seems like it would sometimes be a useful function, and maybe
> >> > someone will point out a package that already contains it.  But if
> not,
> >> > why would it belong in base R?
> >> >
> >>
> >> If someone already implemented it, that would great indeed. I think it
> is
> >> a
> >> very general and basic function, hence base R could be a good place for
> >> it?
> >>
> >> But this is probably not a good reason; maybe someone from the R core
> team
> >> can shed some light on how they decide whether or not to include a
> >> function
> >> in base R?
> >>
> >>
> >> > Duncan Murdoch
> >> >
> >>
> >>         [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> >
> >
> > --
> > Michael Lawrence
> > Scientist, Bioinformatics and Computational Biology
> > Genentech, A Member of the Roche Group
> > Office +1 (650) 225-7760
> > [hidden email]
> >
> > Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Sent from Gmail Mobile

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

MorganMorgan
In reply to this post by Joris FA Meys
I think you are confusing package and function here. Plus some of the R
Core packages, that you mention, contain functions that should probably be
replaced by functions with better implementation from packages on CRAN.

Best regards
Morgan

On Fri, 11 Oct 2019 15:22 Joris Meys, <[hidden email]> wrote:

>
>
> On Fri, Oct 11, 2019 at 3:55 PM Morgan Morgan <[hidden email]>
> wrote:
>
>> How do you prove usefulness of a feature?
>> Do you have an example of a feature that has been added after proving to
>> be
>> useful in the package space first?
>>
>> Thank you,
>> Morgan
>>
>
> The parallel package (a base package like utils, stats, ...) was added as
> a drop-in replacement of the packages snow and multicore for parallel
> computing. That's one example, but sure there's more.
>
> Kind regards
> Joris
>
> --
> Joris Meys
> Statistical consultant
>
> Department of Data Analysis and Mathematical Modelling
> Ghent University
> Coupure Links 653, B-9000 Gent (Belgium)
>
> <https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>
>
> -----------
> Biowiskundedagen 2018-2019
> http://www.biowiskundedagen.ugent.be/
>
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Gabor Grothendieck
In reply to this post by MorganMorgan
Using the example in the link here are two one-liners:

  A <- c(2,3,4,1,2,3,4,1,1,2)
  x <- c(1,2)

  # 1 - zoo
  library(zoo)
  which( rollapply(A, length(x), identical, x, fill = FALSE, align = "left") )
  ## [1] 4 9

  # 2 - Base R using conversion to character
  gregexpr(paste(x, collapse = ""), paste(A, collapse = ""))[[1]]
  ## [1] 4 9
  ...snip ...

On Fri, Oct 11, 2019 at 3:45 AM Morgan Morgan <[hidden email]> wrote:

>
> Hi All,
>
> I was looking for a function to find a small matrix inside a larger matrix
> in R similar to the one described in the following link:
>
> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
>
> I couldn't find anything.
>
> The above function can be seen as a "generalisation" of the "which"
> function as well as the function described in the following post:
>
> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
>
> Would be possible to add such a function to base R?
>
> I am happy to work with someone from the R core team (if you wish) and
> suggest an implementation in C.
>
> Thank you
> Best regards,
> Morgan
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Avraham Adler
In reply to this post by MorganMorgan
Perhaps. But aren’t you looking to implementation a function which finds a
submatrix? If I’m confused, please accept my apologies.

Avi

On Fri, Oct 11, 2019 at 10:43 AM Morgan Morgan <[hidden email]>
wrote:

> I think you are confusing package and function here. Plus some of the R
> Core packages, that you mention, contain functions that should probably be
> replaced by functions with better implementation from packages on CRAN.
>
> Best regards
> Morgan
>
> On Fri, 11 Oct 2019 15:22 Joris Meys, <[hidden email]> wrote:
>
> >
> >
> > On Fri, Oct 11, 2019 at 3:55 PM Morgan Morgan <[hidden email]
> >
> > wrote:
> >
> >> How do you prove usefulness of a feature?
> >> Do you have an example of a feature that has been added after proving to
> >> be
> >> useful in the package space first?
> >>
> >> Thank you,
> >> Morgan
> >>
> >
> > The parallel package (a base package like utils, stats, ...) was added as
> > a drop-in replacement of the packages snow and multicore for parallel
> > computing. That's one example, but sure there's more.
> >
> > Kind regards
> > Joris
> >
> > --
> > Joris Meys
> > Statistical consultant
> >
> > Department of Data Analysis and Mathematical Modelling
> > Ghent University
> > Coupure Links 653, B-9000 Gent (Belgium)
> >
> > <
> https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g
> >
> >
> > -----------
> > Biowiskundedagen 2018-2019
> > http://www.biowiskundedagen.ugent.be/
> >
> > -------------------------------
> > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Sent from Gmail Mobile

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Gabor Grothendieck
In reply to this post by Gabor Grothendieck
Also note that the functionality discussed could be regarded as a generalization
of matrix multiplication where *  and + are general functions and in this case
we have * replaced by == and + replaced by &.

On Fri, Oct 11, 2019 at 10:46 AM Gabor Grothendieck
<[hidden email]> wrote:

>
> Using the example in the link here are two one-liners:
>
>   A <- c(2,3,4,1,2,3,4,1,1,2)
>   x <- c(1,2)
>
>   # 1 - zoo
>   library(zoo)
>   which( rollapply(A, length(x), identical, x, fill = FALSE, align = "left") )
>   ## [1] 4 9
>
>   # 2 - Base R using conversion to character
>   gregexpr(paste(x, collapse = ""), paste(A, collapse = ""))[[1]]
>   ## [1] 4 9
>   ...snip ...
>
> On Fri, Oct 11, 2019 at 3:45 AM Morgan Morgan <[hidden email]> wrote:
> >
> > Hi All,
> >
> > I was looking for a function to find a small matrix inside a larger matrix
> > in R similar to the one described in the following link:
> >
> > https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
> >
> > I couldn't find anything.
> >
> > The above function can be seen as a "generalisation" of the "which"
> > function as well as the function described in the following post:
> >
> > https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
> >
> > Would be possible to add such a function to base R?
> >
> > I am happy to work with someone from the R core team (if you wish) and
> > suggest an implementation in C.
> >
> > Thank you
> > Best regards,
> > Morgan
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com



--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Joris FA Meys
In reply to this post by MorganMorgan
As a package is a collection of functions, and as "base" is not used to
refer to the base package but to all packages that form "base R" (so utils,
graphics, stats, methods, parallel, ...), the functions in the parallel
package are one example of functions incorporated in "base R" from a
package. Actually two, because the functions in parallel are based on both
snow and multicore.

This has no relation to changes in implementation (which often don't happen
due to back-compatibility issues in edge cases).

Kind regards
Joris

On Fri, Oct 11, 2019 at 4:42 PM Morgan Morgan <[hidden email]>
wrote:

> I think you are confusing package and function here. Plus some of the R
> Core packages, that you mention, contain functions that should probably be
> replaced by functions with better implementation from packages on CRAN.
>
> Best regards
> Morgan
>
> On Fri, 11 Oct 2019 15:22 Joris Meys, <[hidden email]> wrote:
>
>>
>>
>> On Fri, Oct 11, 2019 at 3:55 PM Morgan Morgan <[hidden email]>
>> wrote:
>>
>>> How do you prove usefulness of a feature?
>>> Do you have an example of a feature that has been added after proving to
>>> be
>>> useful in the package space first?
>>>
>>> Thank you,
>>> Morgan
>>>
>>
>> The parallel package (a base package like utils, stats, ...) was added as
>> a drop-in replacement of the packages snow and multicore for parallel
>> computing. That's one example, but sure there's more.
>>
>> Kind regards
>> Joris
>>
>> --
>> Joris Meys
>> Statistical consultant
>>
>> Department of Data Analysis and Mathematical Modelling
>> Ghent University
>> Coupure Links 653, B-9000 Gent (Belgium)
>>
>> <https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>
>>
>> -----------
>> Biowiskundedagen 2018-2019
>> http://www.biowiskundedagen.ugent.be/
>>
>> -------------------------------
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>
>

--
Joris Meys
Statistical consultant

Department of Data Analysis and Mathematical Modelling
Ghent University
Coupure Links 653, B-9000 Gent (Belgium)
<https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>

-----------
Biowiskundedagen 2018-2019
http://www.biowiskundedagen.ugent.be/

-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

MorganMorgan
In reply to this post by Avraham Adler
Your answer makes much more sense to me.
I will probably end up adding the function to a package.
Some processes and decisions on how R is developed seems to be obscure to
me.

Thank you
Morgan

On Fri, 11 Oct 2019 15:30 Avraham Adler, <[hidden email]> wrote:

> It’s rather difficult. For example, the base R Kendall tau is written with
> the naive O(n^2). The much faster O(n log n) implementation was programmed
> and is in the pcaPP package. When I say much faster, I mean that my
> implementation in Excel VBA was faster than R for 10,000 or so pairs.
> R-Core decided not to implement that code, and instead made a note about
> the faster implementation living in pcaPP in the help for “cor”. See [1]
> for the 2012 discussion. My point is it’s really really difficult to get
> something in Base R. Develop it well, put it in a package, and you have
> basically the same result.
>
> Avi
>
> [1] https://stat.ethz.ch/pipermail/r-devel/2012-June/064351.html
>
> On Fri, Oct 11, 2019 at 9:55 AM Morgan Morgan <[hidden email]>
> wrote:
>
>> How do you prove usefulness of a feature?
>> Do you have an example of a feature that has been added after proving to
>> be
>> useful in the package space first?
>>
>> Thank you,
>> Morgan
>>
>> On Fri, 11 Oct 2019 13:53 Michael Lawrence, <[hidden email]>
>> wrote:
>>
>> > Thanks for this interesting suggestion, Morgan. While there is no strict
>> > criteria for base R inclusion, one criterion relevant in this case is
>> that
>> > the usefulness of a feature be proven in the package space first.
>> >
>> > Michael
>> >
>> >
>> > On Fri, Oct 11, 2019 at 5:19 AM Morgan Morgan <
>> [hidden email]>
>> > wrote:
>> >
>> >> On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <[hidden email]>
>> >> wrote:
>> >>
>> >> > On 11/10/2019 6:44 a.m., Morgan Morgan wrote:
>> >> > > Hi All,
>> >> > >
>> >> > > I was looking for a function to find a small matrix inside a larger
>> >> > matrix
>> >> > > in R similar to the one described in the following link:
>> >> > >
>> >> > >
>> >> >
>> >>
>> https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
>> >> > >
>> >> > > I couldn't find anything.
>> >> > >
>> >> > > The above function can be seen as a "generalisation" of the "which"
>> >> > > function as well as the function described in the following post:
>> >> > >
>> >> > >
>> >> >
>> >>
>> https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
>> >> > >
>> >> > > Would be possible to add such a function to base R?
>> >> > >
>> >> > > I am happy to work with someone from the R core team (if you wish)
>> and
>> >> > > suggest an implementation in C.
>> >> >
>> >> > That seems like it would sometimes be a useful function, and maybe
>> >> > someone will point out a package that already contains it.  But if
>> not,
>> >> > why would it belong in base R?
>> >> >
>> >>
>> >> If someone already implemented it, that would great indeed. I think it
>> is
>> >> a
>> >> very general and basic function, hence base R could be a good place for
>> >> it?
>> >>
>> >> But this is probably not a good reason; maybe someone from the R core
>> team
>> >> can shed some light on how they decide whether or not to include a
>> >> function
>> >> in base R?
>> >>
>> >>
>> >> > Duncan Murdoch
>> >> >
>> >>
>> >>         [[alternative HTML version deleted]]
>> >>
>> >> ______________________________________________
>> >> [hidden email] mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-devel
>> >>
>> >
>> >
>> > --
>> > Michael Lawrence
>> > Scientist, Bioinformatics and Computational Biology
>> > Genentech, A Member of the Roche Group
>> > Office +1 (650) 225-7760
>> > [hidden email]
>> >
>> > Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube
>> >
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> --
> Sent from Gmail Mobile
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Gabor Grothendieck
In reply to this post by Gabor Grothendieck
I pressed return too soon.

If we had such a multiply then

   which(embed(A, x) %==.&% reverse(x))

On Fri, Oct 11, 2019 at 10:57 AM Gabor Grothendieck
<[hidden email]> wrote:

>
> Also note that the functionality discussed could be regarded as a generalization
> of matrix multiplication where *  and + are general functions and in this case
> we have * replaced by == and + replaced by &.
>
> On Fri, Oct 11, 2019 at 10:46 AM Gabor Grothendieck
> <[hidden email]> wrote:
> >
> > Using the example in the link here are two one-liners:
> >
> >   A <- c(2,3,4,1,2,3,4,1,1,2)
> >   x <- c(1,2)
> >
> >   # 1 - zoo
> >   library(zoo)
> >   which( rollapply(A, length(x), identical, x, fill = FALSE, align = "left") )
> >   ## [1] 4 9
> >
> >   # 2 - Base R using conversion to character
> >   gregexpr(paste(x, collapse = ""), paste(A, collapse = ""))[[1]]
> >   ## [1] 4 9
> >   ...snip ...
> >
> > On Fri, Oct 11, 2019 at 3:45 AM Morgan Morgan <[hidden email]> wrote:
> > >
> > > Hi All,
> > >
> > > I was looking for a function to find a small matrix inside a larger matrix
> > > in R similar to the one described in the following link:
> > >
> > > https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix
> > >
> > > I couldn't find anything.
> > >
> > > The above function can be seen as a "generalisation" of the "which"
> > > function as well as the function described in the following post:
> > >
> > > https://coolbutuseless.github.io/2018/04/03/finding-a-length-n-needle-in-a-haystack/
> > >
> > > Would be possible to add such a function to base R?
> > >
> > > I am happy to work with someone from the R core team (if you wish) and
> > > suggest an implementation in C.
> > >
> > > Thank you
> > > Best regards,
> > > Morgan
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
> >
> > --
> > Statistics & Software Consulting
> > GKX Group, GKX Associates Inc.
> > tel: 1-877-GKX-GROUP
> > email: ggrothendieck at gmail.com
>
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com



--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Pages, Herve
In reply to this post by MorganMorgan
Has someone looked into the image processing area for this? That sounds
a little bit too high-level for base R to me (and I would be surprised
if any mainstream programming language had this kind of functionality
built-in).

H.

On 10/11/19 03:44, Morgan Morgan wrote:

> Hi All,
>
> I was looking for a function to find a small matrix inside a larger matrix
> in R similar to the one described in the following link:
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mathworks.com_matlabcentral_answers_194708-2Dindex-2Da-2Dsmall-2Dmatrix-2Din-2Da-2Dlarger-2Dmatrix&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=9Eu0WySIEzrWuYXFhwhHETpZQzi6hHLd84DZsbZsXYY&e=
>
> I couldn't find anything.
>
> The above function can be seen as a "generalisation" of the "which"
> function as well as the function described in the following post:
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__coolbutuseless.github.io_2018_04_03_finding-2Da-2Dlength-2Dn-2Dneedle-2Din-2Da-2Dhaystack_&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=qZ3SJ8t8zEDA-em4WT7gBmN66qvvCKKKXRJunoF6P3k&e=
>
> Would be possible to add such a function to base R?
>
> I am happy to work with someone from the R core team (if you wish) and
> suggest an implementation in C.
>
> Thank you
> Best regards,
> Morgan
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=tyVSs9EYVBd_dmVm1LSC23GhUzbBv8ULvtsveo-COoU&e=
>

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: [hidden email]
Phone:  (206) 667-5791
Fax:    (206) 667-1319
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

Gabor Grothendieck
The link you posted used the same inputs as in my example. If that is
not what you meant maybe
a different example is needed.
Regards.

On Fri, Oct 11, 2019 at 2:39 PM Pages, Herve <[hidden email]> wrote:

>
> Has someone looked into the image processing area for this? That sounds
> a little bit too high-level for base R to me (and I would be surprised
> if any mainstream programming language had this kind of functionality
> built-in).
>
> H.
>
> On 10/11/19 03:44, Morgan Morgan wrote:
> > Hi All,
> >
> > I was looking for a function to find a small matrix inside a larger matrix
> > in R similar to the one described in the following link:
> >
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mathworks.com_matlabcentral_answers_194708-2Dindex-2Da-2Dsmall-2Dmatrix-2Din-2Da-2Dlarger-2Dmatrix&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=9Eu0WySIEzrWuYXFhwhHETpZQzi6hHLd84DZsbZsXYY&e=
> >
> > I couldn't find anything.
> >
> > The above function can be seen as a "generalisation" of the "which"
> > function as well as the function described in the following post:
> >
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__coolbutuseless.github.io_2018_04_03_finding-2Da-2Dlength-2Dn-2Dneedle-2Din-2Da-2Dhaystack_&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=qZ3SJ8t8zEDA-em4WT7gBmN66qvvCKKKXRJunoF6P3k&e=
> >
> > Would be possible to add such a function to base R?
> >
> > I am happy to work with someone from the R core team (if you wish) and
> > suggest an implementation in C.
> >
> > Thank you
> > Best regards,
> > Morgan
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=tyVSs9EYVBd_dmVm1LSC23GhUzbBv8ULvtsveo-COoU&e=
> >
>
> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: [hidden email]
> Phone:  (206) 667-5791
> Fax:    (206) 667-1319
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: New matrix function

MorganMorgan
Basically the problem is to find the position of a submatrix inside a
larger matrix. Here are some links describing the problem:

https://stackoverflow.com/questions/10529278/fastest-way-to-find-a-m-x-n-submatrix-in-m-x-n-matrix

https://stackoverflow.com/questions/16750739/find-a-matrix-in-a-big-matrix

Best
Morgan

On Fri, 11 Oct 2019 23:36 Gabor Grothendieck, <[hidden email]>
wrote:

> The link you posted used the same inputs as in my example. If that is
> not what you meant maybe
> a different example is needed.
> Regards.
>
> On Fri, Oct 11, 2019 at 2:39 PM Pages, Herve <[hidden email]> wrote:
> >
> > Has someone looked into the image processing area for this? That sounds
> > a little bit too high-level for base R to me (and I would be surprised
> > if any mainstream programming language had this kind of functionality
> > built-in).
> >
> > H.
> >
> > On 10/11/19 03:44, Morgan Morgan wrote:
> > > Hi All,
> > >
> > > I was looking for a function to find a small matrix inside a larger
> matrix
> > > in R similar to the one described in the following link:
> > >
> > >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mathworks.com_matlabcentral_answers_194708-2Dindex-2Da-2Dsmall-2Dmatrix-2Din-2Da-2Dlarger-2Dmatrix&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=9Eu0WySIEzrWuYXFhwhHETpZQzi6hHLd84DZsbZsXYY&e=
> > >
> > > I couldn't find anything.
> > >
> > > The above function can be seen as a "generalisation" of the "which"
> > > function as well as the function described in the following post:
> > >
> > >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__coolbutuseless.github.io_2018_04_03_finding-2Da-2Dlength-2Dn-2Dneedle-2Din-2Da-2Dhaystack_&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=qZ3SJ8t8zEDA-em4WT7gBmN66qvvCKKKXRJunoF6P3k&e=
> > >
> > > Would be possible to add such a function to base R?
> > >
> > > I am happy to work with someone from the R core team (if you wish) and
> > > suggest an implementation in C.
> > >
> > > Thank you
> > > Best regards,
> > > Morgan
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=v96tqHMO3CLNBS7KTmdshM371i6W_v8_2H5bdVy_KHo&s=tyVSs9EYVBd_dmVm1LSC23GhUzbBv8ULvtsveo-COoU&e=
> > >
> >
> > --
> > Hervé Pagès
> >
> > Program in Computational Biology
> > Division of Public Health Sciences
> > Fred Hutchinson Cancer Research Center
> > 1100 Fairview Ave. N, M1-B514
> > P.O. Box 19024
> > Seattle, WA 98109-1024
> >
> > E-mail: [hidden email]
> > Phone:  (206) 667-5791
> > Fax:    (206) 667-1319
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel