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

Thomas P. Colson tpcolson at ncsu.edu
Tue Oct 10 21:46:11 CEST 2006


>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
tpcolson at ncsu.edu

Schedule: www4.ncsu.edu/~tpcolson



More information about the R-help mailing list