From ggrothend|eck @end|ng |rom gm@||@com  Fri Oct 11 16:57:24 2019
From: ggrothend|eck @end|ng |rom gm@||@com (Gabor Grothendieck)
Date: Fri, 11 Oct 2019 10:57:24 -0400
Subject: [Rd] New matrix function
In-Reply-To: <CAP01uRn5KxHwB3o+9E9f2b+i-jAzpvXn-D5eNitqn57-oWVTPw@mail.gmail.com>
References: <CAL0QV_OHN1+c2ZMO28v9gB1Y-0c+2zL57bDCgcZse13bZ8--eQ@mail.gmail.com>
 <CAP01uRn5KxHwB3o+9E9f2b+i-jAzpvXn-D5eNitqn57-oWVTPw@mail.gmail.com>
Message-ID: <CAP01uRm73EP-RcL+3s7QQiDfEfEOzZwOx_Jp84qhU3NvoF+_+g@mail.gmail.com>

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 at 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 at 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 at 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



[Rd] New matrix function
Gabor Grothendieck