[R] creating a matrix of ranked column data
Peter Langfelder
peter.langfelder at gmail.com
Mon Jul 18 00:22:27 CEST 2011
On Sun, Jul 17, 2011 at 11:18 AM, christian krahforst
<ckrahforst at gmail.com> wrote:
> I have a data frame (gom) or a matrix of trace metal data and some other
> observations from water column samples taken at sea (e.g., 19 samples
> (rows), 19 variables)
> I can calc. the rank individually from each column of the attached object.
> How can I create a matrix that contains the ranked data for each variable
> (either 1-19, ties=avg)?
> For example:
>>gom<-read.csv ("gomdata.csv")
>>rank(Phaeo)
> [1] 3.5 1.0 2.0 5.0 15.0 19.0 12.0 7.0 3.5 13.0 17.5 9.0 6.0 14.0
> 16.0
> [16] 11.0 9.0 9.0 17.5
>
> I'd like to return an object (e.g., "gomr <-" ) that has each column
> individually ranked (for data normalization, btw).
Try
apply(gom, 2, rank)
HTH,
Peter
More information about the R-help
mailing list