See ?order. In particular, if you do: a <- order(names(vec)), a will contain the indices of the vector in order, so vec[a] will be in the correct order. Sean On 6/17/04 7:10 AM, "Luis Rideau Cruz" <Luisr at frs.fo> wrote:> Hi all > > I have a vector like this > > 2003 2002 2001 2000 1999 1998 1997 1996 > 106 105 106 106 105 106 101 107 > > How can I get it sorted right(1996....2003)? > > Thank you > > Luis Ridao Cruz > Fiskiranns??knarstovan > N??at??n 1 > P.O. Box 3051 > FR-110 T??rshavn > Faroe Islands > Phone: +298 353900 > Phone(direct): +298 353912 > Mobile: +298 580800 > Fax: +298 353901 > E-mail: luisr at frs.fo > Web: www.frs.fo > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Hi all I have a vector like this 2003 2002 2001 2000 1999 1998 1997 1996 106 105 106 106 105 106 101 107 How can I get it sorted right(1996....2003)? Thank you Luis Ridao Cruz Fiskiranns??knarstovan N??at??n 1 P.O. Box 3051 FR-110 T??rshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: luisr at frs.fo Web: www.frs.fo
r-help-bounces at stat.math.ethz.ch wrote on 17/06/2004 13:10:35:> Hi all > > I have a vector like this > > 2003 2002 2001 2000 1999 1998 1997 1996 > 106 105 106 106 105 106 101 107 > > How can I get it sorted right(1996....2003)?> rev(1:4)[1] 4 3 2 1 HTH, Tobias
Hi! I assume that 2003 2002 are the names of your vector myvector myvector[order(names(myvector))] Eryk *********** REPLY SEPARATOR *********** On 6/17/2004 at 12:10 PM Luis Rideau Cruz wrote:>>>Hi all >>> >>>I have a vector like this >>> >>>2003 2002 2001 2000 1999 1998 1997 1996 >>> 106 105 106 106 105 106 101 107 >>> >>>How can I get it sorted right(1996....2003)? >>> >>>Thank you >>> >>>Luis Ridao Cruz >>>Fiskiranns??knarstovan >>>N??at??n 1 >>>P.O. Box 3051 >>>FR-110 T??rshavn >>>Faroe Islands >>>Phone: +298 353900 >>>Phone(direct): +298 353912 >>>Mobile: +298 580800 >>>Fax: +298 353901 >>>E-mail: luisr at frs.fo >>>Web: www.frs.fo >>> >>>______________________________________________ >>>R-help at stat.math.ethz.ch mailing list >>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help >>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlDipl. bio-chem. Eryk Witold Wolski @ MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: wolski at molgen.mpg.de ---W-W---- http://www.molgen.mpg.de/~wolski