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. - adschai [[alternative HTML version deleted]]
On Sun, 2007-03-18 at 02:52 +0000, 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)I presume you meant: b <- c(3, 2, 1) ?> But what operator I need to put to my original vector 'a' to obtain 'b'? Please let me know. Thank you.See ?rev a <- c(1, 2, 3) b <- rev(a)> b[1] 3 2 1 HTH, Marc Schwartz
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)> - adschaiHaris Skiadas Department of Mathematics and Computer Science Hanover College