[R] sorting a (homogenous) list of objects, based on a a field of the objects

Rajarshi Guha rajarshi.guha at gmail.com
Sat Sep 11 23:53:42 CEST 2010


Him I have a list of S4 objects. Each object has a field called name,
and what I'd like to do is to sort the list based on the value of
name. Currently I'm using the following code

tmp <- unlist(lapply(fps, function(x) as.integer(x at name)))
tmp <- order(tmp, decreasing=FALSE)
fps <- fps[ tmp ]

this seems a little klunky and I was wondering if there was another
way to do this (by analogy with comparator functions in Java)

Thanks,

-- 
Rajarshi Guha
NIH Chemical Genomics Center



More information about the R-help mailing list