Hello,

I am trying to help a colleague with an R problem (see below) to whit I can only generate a very inelegant solution. Any advice would be welcome.

Thanks,
Brian

If you have two matrices, say a species by trait matrix (Matrix 1 below) and a plot by species matrix (Matrix 2 below), is there a straightforward way to prune one matrix so that the species list matches those in a second matrix? Ideally, I need to prune both matrices so that they include only the species found in both. In this case, the two matrices would therefore include only sp1,sp4,sp5.

Thank you so much for any suggestions!

E.g.:
Matrix 1:
        Trait1
sp1 1.0
sp2 1.2
sp4 3.1
sp5 4.0
sp7 4.5

Matrix 2
                sp1     sp3 sp4 sp5 sp6
plot1   1       2       5       1       0
plot2   3       0       1       2       5       
plot3   1       1       2       3       1
plot4   0       1       2       1       0


Brian C. McCarthy, Ph.D.
Professor of Forest Ecology
Dept. of Environmental & Plant Biology
317 Porter Hall
Ohio University
Athens, OH  45701-2979  USA

T: 740-593-1615
F: 740-593-1130
E: mccar...@ohio.edu
W: 
http://www.plantbio.ohiou.edu/index.php/directory/faculty_page/brian_mccarthy/

______________________________________________
R-help@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.

Reply via email to