Re: [R] mirror vector?

From: Patrick Burns <pburns_at_pburns.seanet.com>
Date: Fri 28 Jul 2006 - 19:12:06 EST

Another approach is:

mat[nrow(mat):1, ]

Patrick Burns
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Jacques VESLOT wrote:

> > mat <- matrix(1:16,4,4)
> > mat
> [,1] [,2] [,3] [,4]
>[1,] 1 5 9 13
>[2,] 2 6 10 14
>[3,] 3 7 11 15
>[4,] 4 8 12 16
> > apply(mat,2,rev)
> [,1] [,2] [,3] [,4]
>[1,] 4 8 12 16
>[2,] 3 7 11 15
>[3,] 2 6 10 14
>[4,] 1 5 9 13
>
>-------------------------------------------------------------------
>Jacques VESLOT
>
>CNRS UMR 8090
>I.B.L (2ème étage)
>1 rue du Professeur Calmette
>B.P. 245
>59019 Lille Cedex
>
>Tel : 33 (0)3.20.87.10.44
>Fax : 33 (0)3.20.87.10.31
>
>http://www-good.ibl.fr
>-------------------------------------------------------------------
>
>
>niederlein-rstat@yahoo.de a écrit :
>
>
>>Hello,
>>
>>I'm an absolut beginner with R and now I got a 2D vector with numbers. I would like to mirror this vector now by the rows (so that the first row becomes last, second becomes one before last, ...).
>>I don't know if there is any method I can use to do this.
>>Could you please help me?
>>
>>Antje
>>
>>
>>---------------------------------
>>Was Sie schon immer wissen wollten aber nie zu Fragen trauten? Yahoo! Clever hilft Ihnen.
>> [[alternative HTML version deleted]]
>>
>>______________________________________________
>>R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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. Received on Fri Jul 28 20:27:08 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 28 Jul 2006 - 22:17:25 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.