[R] How to assign a rank to a range of values..

From: Thomas P. Colson <tpcolson_at_ncsu.edu>
Date: Tue 10 Oct 2006 - 19:46:11 GMT

>From the following:

basin.map <- readAsciiGrid("c:/temp/area.asc", colname="area")

I have a SpatialGridDataFrame which has the x and y cordinate of a cell, and the drainage area of that cell. There are many cells with a low drainage area (in my case, 33000 with an area of 37.16) and one cell with the highest drainage area (again, in my case, a drainage area of of 800000).

What I'd like to do, is to rank the drainage area cells based upon the number of times they occur, with a rank of 100 going to the cells with area=37.16, and 1 going to the cell(s) with area=800000). There are 6,000 different drainage areas out of 180,000 cells in this grid, so the ranks would have values like 100, 99.01, 57.34, 20, 1.08, 1 and so forth.

I have been struggeling with the split, length and rank commands in R, but can't seem to figure out how to "attach" a new column (or make a new dataset) that has a colums of ranks, or how to calculate the rank.

Thanks for any help.

Thomas Colson
North Carolina State University
Department of Forestry and Environmental Resources (919)624-6329
(919)515 3434

Schedule: www4.ncsu.edu/~tpcolson

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Oct 11 05:48:36 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 11 Oct 2006 - 08:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.