[R] Repeated Procedures

Gray Calhoun gray.calhoun at gmail.com
Tue Jul 27 02:15:44 CEST 2010


Hi Alexandre,
  You can either initialize the table (using, maybe, all NA entries)
and then put a for loop around your analysis code and write to
different entries or (and this is probably the better way to do it,
but might be more time consuming the first time you try) put the
matrices into an array and call apply on it.  The help pages for array
and apply will give you the right syntax and more details.
--Gray

On Mon, Jul 26, 2010 at 4:41 PM,  <afsouza at unisinos.br> wrote:
> Dear Friends,
>
>    Using package Vegan, I need to calculate Shannons Diversity index
> and Pielou's Evenness for a set of 20 study areas. Each area is
> represented by a matrix of 25 sample plots x tree species. The code is
> as following, where data stands for the data matrix of any of the 20
> areas:
>
> S <- specnumber(data)
> H <- diversity(data)
> J <- H/log(S)
>
>     I indexed the 20 areas by a column with the number of each of the
> areas and have been trying to formulate a code to iterate this procedure
> for each of the 20 areas and save the results in a table, but I have not
> been successful.
>
>    Do anyone have a hint on how to do that?
>
>    Thaks very much in advance,
>
>    Sincerely,
>
>    Alexandre
>
> Dr. Alexandre F. Souza
> Programa de Pós-Graduação em Biologia: Diversidade e Manejo da Vida
> Silvestre
> Universidade do Vale do Rio dos Sinos (UNISINOS)
> Av. UNISINOS 950 - C.P. 275, São Leopoldo 93022-000, RS  - Brasil
> Telefone: (051)3590-8477 ramal 1263
> Skype: alexfadigas
> afsouza at unisinos.br
> http://www.unisinos.br/laboratorios/lecopop
>
> --
> Esta mensagem foi verificada pelo sistema de antivírus e
>  acredita-se estar livre de perigo.
>
>
> ______________________________________________
> R-help at r-project.org 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.
>
>



-- 
Gray Calhoun

Assistant Professor of Economics, Iowa State University
http://www.econ.iastate.edu/~gcalhoun/



More information about the R-help mailing list