Hello,

Something like this?


different <- function(x, y) x == 1 & y == 0

set.seed(7054)
mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
rownames(mat) <- LETTERS[1:5]
colnames(mat) <- sprintf("D%03d", 1:100)

different(mat["B",], mat["E",])



Hope this helps,

Rui Barradas

Em 27-09-2013 11:48, Elaine Kuo escreveu:
Dear List,



I want to compare the presence and absence of bird species based on the
sites in a matrix.

The matrix has 5 rows for Island A, B, C, D, and E.

It has 100 columns for bird species D001-D100.

In each cell of the matrix,

the presence-absence of bird species will be recorded as 1 or 0.

(For example, if species D001 is found on Island D,

the matrix cell of species D001 and Island D will be 1.)



Now I want to know the different bird species between Island B and E.

In other words, I would like to find out bird species present (1) on Island
B but absent (0)on island E, and vice versa (absent (0) on Island B but
present (1)on island E).



Please kindly advise how to code the purpose above.

Thank you in advance.



Elaine

        [[alternative HTML version deleted]]

______________________________________________
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.


______________________________________________
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