[R] Flipping a vector

Charilaos Skiadas
Sun, 18 Mar 2007 03:02:19 -0000

On Mar 17, 2007, at 10:52 PM, adschai at optonline.net wrote:

> Hi all - A stupid question here, my apology. I would like to know
> how can I flip a vector in R? For example, I have a vector:
>
> a = c(1,2,3)
>
> I would like my vector b to have the following value
>
> b = c(1,2,3)
>
> But what operator I need to put to my original vector 'a' to obtain
> 'b'? Please let me know. Thank you.
>

I can only assume you wanted b=c(3,2,1). In that case, try rev(a)

> - adschai

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College