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/
Hadley Wickham <hadley <at> 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 >
Hadley: Dunno. 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. Cheers, Bert On Sat, Dec 31, 2011 at 7:08 AM, Hadley Wickham <hadley at rice.edu> wrote:> 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/ > > ______________________________________________ > R-help at r-project.org 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.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Hadley, Presumably for fliplr you meant ncol(x) fliplr <- function(x) x[, ncol(x):1] Bill On Dec 31, 2011, at 9:08 AM, Hadley Wickham wrote:> 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/ > > ______________________________________________ > R-help at r-project.org 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. >William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Use R for psychology http://personality-project.org/r It is 6 minutes to midnight http://www.thebulletin.org
> 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/