Base function for flipping matrices

8 messages
Open this post in threaded view
|

Base function for flipping matrices

 Hi all, Are there base functions that do the equivalent of this? fliptb <- function(x) x[nrow(x):1, ] fliplr <- function(x) x[, nrow(x):1] Obviously not hard to implement (although it needs some more checks), just wondering if it had already been implemented. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

Re: Base function for flipping matrices

 Hadley Wickham rice.edu> writes: > See functions flipud(), fliplr() in package 'matlab' (or 'pracma'). Those are the names of corresponding functions in MATLAB. Hans Werner > Hi all, > > Are there base functions that do the equivalent of this? > > fliptb <- function(x) x[nrow(x):1, ] > fliplr <- function(x) x[, nrow(x):1] > > Obviously not hard to implement (although it needs some more checks), > just wondering if it had already been implemented. > > Hadley > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

Re: Base function for flipping matrices

Open this post in threaded view
|

Re: Base function for flipping matrices

Open this post in threaded view
|

Re: Base function for flipping matrices

 In reply to this post by Bert Gunter > But if not,  it seems to me that it should be added as an array method > to ?rev with an argument specifying which indices to rev() over. Yes, agreed.  Sometimes arrays seem like something bolted onto R that is missing a lot of functionality. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

Re: Base function for flipping matrices

 Hadley, Your request is reminding me of the analysis of aray functions in Philip S Abrams dissertation http://www.slac.stanford.edu/cgi-wrap/getdoc/slac-r-114.pdfAN APL MACHINE The section that starts on page 17 with this paragraph is the one that immediately applies C. The Standard Form for Select Expressions In this section the selection operators considered are take, drop, reversal, transpose, and subscripting by scalars or _J-vectors. Because of the similarity among the selection operators, we might expect that an expression consisting only of selection operators applied to a single array could be expressed equivalently in terms of some simpler set of operators. This expectation is fulfilled in the standard form for select expressions, to be discussed below. I look forward to seeing where you take this in R. Rich On Mon, Jan 2, 2012 at 8:38 AM, Hadley Wickham <[hidden email]> wrote: > > But if not,  it seems to me that it should be added as an array method > > to ?rev with an argument specifying which indices to rev() over. > > Yes, agreed.  Sometimes arrays seem like something bolted onto R that > is missing a lot of functionality. > > Hadley > > -- > Assistant Professor / Dobelman Family Junior Chair > Department of Statistics / Rice University > http://had.co.nz/> > ______________________________________________ > [hidden email] mailing list > 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.