ranks to relative abundances using geometric series
I have data where plant species have been ranked in terms of
contribution to standing biomass, and where the abundance ratio between
the 5th and 1st species has been estimated. I'm using the geometric
series to convert the ranks to relative abundances from this ratio.
It's pretty easy to do so in R. However, I could find no function
already programmed. I think this could be useful instead of having to
rewrite it every time. If one such function exists, can someone please
tell me its name/location, before I go through the hassle of writing
an .Rd help file and adding it to an existing package?
A simple example, but obviously could be improved to allow more options
(e.g. na.rm = TRUE, etc):
# ranks = vectors of ranks (e.g. 1, 2, 3, ...)
# k = constant proportion
# inf = infinite series or finite?
rank2abun <- function(ranks, k, inf = TRUE){
if (inf) abun <- 100 * (1 - k) * k^(ranks - 1)
else abun <- 100 * ((1 - k) * k^(ranks - 1) ) / (1 -
k^length(ranks))
return(abun)
}
# test it
1> rank2abun(1:10, k = 0.3)
[1] 70.00000000 21.00000000 6.30000000 1.89000000 0.56700000
0.17010000 0.05103000 0.01530900 0.00459270 0.00137781
Etienne Lalibert? ================================ School of Forestry University of Canterbury Private Bag 4800 Christchurch 8140, New Zealand Phone: +64 3 366 7001 ext. 8365 Fax: +64 3 364 2124 www.elaliberte.info