[R-sig-eco] ranks to relative abundances using geometric series

Etienne Laliberté etiennelaliberte at gmail.com
Mon Apr 19 21:43:48 CEST 2010


How embarrassing. I was so caught up in the methodological details of
that particular field sampling problem that I failed to recognize right
away that this was as simple as:

dgeom(0:9, p = 0.7) * 100

Le vendredi 09 avril 2010 à 14:32 +1200, Etienne Laliberté a écrit :
> 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



More information about the R-sig-ecology mailing list