[R] Reversing order of vector

Philipp Pagel p.pagel at wzw.tum.de
Tue Mar 29 09:44:22 CEST 2011


On Tue, Mar 29, 2011 at 12:20:50AM -0700, Vincy Pyne wrote:
> 
> vect1 = as.character(c("ABC", "XYZ", "LMN", "DEF"))

as.character is unnecessary, here.

> > vect1
> [1] "ABC" "XYZ" "LMN" "DEF"
> 
> I want to reverse the order of this vector as
> 
> vect2 = c("DEF", "LMN", "XYZ", "ABC")

vect2 <- rev(vect1))

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/



More information about the R-help mailing list