Dear list,

I would like to run several analyses to partitioning the variance of the
species composition matrix into spatial and environmental variables, but in
two different scales. Firstly, I'll use the main matrix (in the example
with 30 rows) that combines all samples (sp matrix below). The other
matrices are env and pcnm (both with 30 rows). Then, I'd like to did the
same again, but choosing only the subsamples (a=10 rows, b=10, c=10). Can I
automate these steps instead of repeating the code to every subsample?

sp <- as.data.frame(matrix(sample(c(rep(0, 50), rep(1, 20), rep(2,
10), rep(3, 10))), 30, 30))

env <- as.data.frame(matrix(c(rnorm(30, 3, 5), rnorm(30, 5, 9), rnorm(30,
20, 10), rnorm(30, 50, 20)), 30, 4))

xy <- matrix(sample(rep(1:5, 6)), 30, 2)

sub.sample <- factor(c(rep("a", 10), rep("b", 10), rep("c", 10)))

library(vegan)

pcnm1 <- pcnm(dist(xy))$vectors

partition <- varpart(sp, ~., pcnm1, data=env)

plot(partition)

Thank you in advance,

Thiago.


-- 
Thiago Gonçalves-Souza, Ms.
Universidade Estadual Paulista (UNESP)
Departamento de Zoologia e Botânica
Programa de Pós-Graduação em Biologia Animal (Doutorado)
E-mail alternativo: thiagoaracno@gmail.com
Home page:<http://www.wix.com/thiagocalvesouza/tg-s>

	[[alternative HTML version deleted]]

