[R] merge two matrices
Michael Eisenring
michael.eisenring at gmx.ch
Fri Mar 15 17:17:01 CET 2013
Dear R-help members
I would be grateful if anyone could help me with the following problem: I would like to combine two matrices (SCH_15 and SCH_16, they are attached) which have a species presence/absence x sampling plot structure. The aim would be to have in the end only one matrix which shows all existing species and their presence/absence on all the different plots(an_1, an_2 etc.)
To do this I used the "merge" function in R.
Command:
output<-merge(SCH_15,SCH_16,by="species", all=TRUE)
The problem is that if the same species occurs in both "SCH" files (i.e. species Abutilon longicuspe occurs in both files) it is listed two times in the merged matrix. However, the aim would be that each species is listed only once in the final matrix.
How do I have to modify the R code? I guess I have to replace "all=TRUE" with something else but I can't figure out what it is.
Thank you for your help
Michael
More information about the R-help
mailing list