[Rd] New matrix function
Gabor Grothendieck
ggrothend|eck @end|ng |rom gm@||@com
Fri Oct 11 17:04:43 CEST 2019
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
<ggrothendieck using gmail.com> 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
> <ggrothendieck using gmail.com> 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 <morgan.emailbox using gmail.com> 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]]
> > >
> > > ______________________________________________
> > > R-devel using r-project.org 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
More information about the R-devel
mailing list