[R] Resshufling algorithm (Thiago Souza)

Bernardo Rangel Tura tura at centroin.com.br
Sat Jul 19 17:26:38 CEST 2008


Em Sáb, 2008-07-19 às 11:07 -0300, Thiago Souza escreveu:
> Hi folks!
> 
> I'm a beginner and I'm learning how to use R.
> 
> I need to calculate the value of Simpson Diversity Index (*D*=1-Σ*pi*^2;
> where *p* is the relative abundance of the species* i*) of one sample (e.g.,
> diversity of bromeliad spiders) and test the significance of this value. For
> this I'll need to randomize samples while conserving the observed species
> abundance and sample-size distributions. After this, in need to repeate
> these randomizations 10.000 times to form a null distribution and assessing
> the statistical significance by compare the observad D value with the null
> distribution.
> But unfortunately, I don't know how to run this procedure in R software.
> 
> Please, can anybody help me?
> 
> Thank you in advance
> 

Thiago,

If I understood your problem do you solve using sample, look this
example

data<-rep(letters[1:6],10)

sample<-sample (data,10)
sample
table(sample)

sample<-sample (data,10)
sample
table(sample)

For repeat the sample using "for" 


for (i in 1:10000){
commands
}


-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil



More information about the R-help mailing list