Rajarshi Guha
2003-Nov-27 05:24 UTC
[R] sorting a list structure based on one of its components
Hi, is the following possible? I have a list of vectors which may be numeric or character. Is there any way I can sort all the vectors based on a certain numeric vector? Thanks, ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- I saw Elvis. He sat between me and Bigfoot on the UFO.
Gabor Grothendieck
2003-Nov-27 05:44 UTC
[R] sorting a list structure based on one of its components
Assuming you want to order the components of my.list according to the order of the third one: lapply( my.list, function(x) x[order(my.list[[3]])] ) --- On Thu 11/27, Rajarshi Guha < rxg218 at psu.edu > wrote: From: Rajarshi Guha <rxg218 at psu.edu> To: R <r-help at stat.math.ethz.ch> Subject: [R] sorting a list structure based on one of its components Hi, is the following possible? I have a list of vectors which may be numeric or character. Is there any way I can sort all the vectors based on a certain numeric vector? Thanks,