Re: [R] Base function for flipping matrices

2012-01-02 Thread Hadley Wickham
> 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.pdf
> AN 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.

That's fantastic - thanks for the pointer. One thing I'd like to do
with the plyr package is generate a natural (and minimal) set of
operators for data frames in a similar way APL did for arrays.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
R-help@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.


Re: [R] Base function for flipping matrices

2012-01-02 Thread Claudia Beleites
Hadley,

I started to throw some functions that I needed to be extended to arrays
together as package arrayhelpers. If you consider that a good home for
the new functions, they would be more than welcome.

Currently I have the package at r-forge, but I wouldn't mind github,
either (so far I just use git-svn). Unit tests use svUnit, not testthat,
though.

Happy new year to everyone,

Claudia




Am 02.01.2012 18:38, schrieb Richard M. Heiberger:
> 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.pdf
> AN 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  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/
>>
>> __
>> R-help@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.
>>
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@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.


-- 
Claudia Beleites
Spectroscopy/Imaging
Institute of Photonic Technology
Albert-Einstein-Str. 9
07745 Jena
Germany

email: claudia.belei...@ipht-jena.de
phone: +49 3641 206-133
fax:   +49 2641 206-399

__
R-help@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.


Re: [R] Base function for flipping matrices

2012-01-02 Thread Richard M. Heiberger
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.pdf
AN 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  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/
>
> __
> R-help@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.
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Base function for flipping matrices

2012-01-02 Thread Hadley Wickham
> 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/

__
R-help@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.


Re: [R] Base function for flipping matrices

2011-12-31 Thread William Revelle
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@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 Revellehttp://personality-project.org/revelle.html
Professor  http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern Universityhttp://www.northwestern.edu/
Use R for psychology http://personality-project.org/r
It is 6 minutes to midnighthttp://www.thebulletin.org

__
R-help@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.


Re: [R] Base function for flipping matrices

2011-12-31 Thread Bert Gunter
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  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@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

__
R-help@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.


Re: [R] Base function for flipping matrices

2011-12-31 Thread Hans W Borchers
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
>

__
R-help@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.


[R] Base function for flipping matrices

2011-12-31 Thread Hadley Wickham
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@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.