Re: [R-sig-eco] Combining two matrices

2012-05-13 Thread Peter Solymos
Thiago, It's all about indexing: rn <- union(rownames(matrix1), rownames(matrix2)) cn <- union(colnames(matrix1), colnames(matrix2)) x <- array(0, dim=c(length(rn), length(cn)), dimnames=list(rn, cn)) x[rownames(matrix1), colnames(matrix1)] <- matrix1 x[rownames(matrix2), colnames(matrix2)] <- ma

[R-sig-eco] Combining two matrices

2012-05-13 Thread Thiago Gonçalves-Souza
Dear all, I have two species-by-site matrices and I'd like to combine them in one matrix. The rows (n=20) of each matrix present plants 1-20. So, the new matrix should have 40 rows. As these matrices have some shared species and some exclusive species, the new matrix should have the species from t