[R] Fill a matrix using logical arguments?

Alistair Auffret alistair.auffret at natgeo.su.se
Wed May 26 14:50:32 CEST 2010


Hello all,
I am going slightly mad trying to create a table for running 
co-correspondence analysis.

What I have is seed bank and vegetation data, and my aim  is to see if 
the vegetation found in a site (containing several seed bank samples) 
can predict the composition of a seed bank sample within that site. So 
for this I need two tables with matching rows.

I have created an empty matrix, where the rows correspond to the seed 
bank samples

bank.plot<-matrix(,5,3,dimnames=list(c("AB 01 01", "AB 01 02", "AB 02 
01","AB 03 01","AB 03 02"),c(1:3)))
bank.plot

And I have a matrix where I have presence/absence of species in the 
vegetation at each site.

site.veg<-matrix((c(1,0,1,1,0,1,0,1,1)),3,3,dimnames=list(c("AB 01", "AB 
02", "AB 03")))
site.veg

Is there a way to fill the bank.plot matrix with the results from the 
vegetation survey, duplicating them appropriately to match sites to 
plots, even when the number or sites per plot are unequal? i.e. in my 
example, the row AB 01 in site.veg would be duplicatied for the first 
two rows, AB 02 only once, and AB 03 twice.

Hope you can help!

Many thanks.


-- 

Alistair Auffret
PhD Student

Department of Physical Geography and Quaternary Geology
Stockholm University
106 91 Stockholm
Sweden

+46(0)8 674 7568
+46(0)76 7158975



More information about the R-help mailing list