On 19/07/2013 10:17 AM, Kátia Emidio wrote:
Hi,
  I am a beginner at R and I would like to get information from a matrix,
where the numbers are larger than or equal to 50m . This means that plants
need to be apart at least  50m.  I  need to get the selection as in a way
that I can identify which pair of species are 50m or more apart.

here a peace of my matrix:

    Nauc_calo_1 Nauc_calo_2 Nauc_calo_3  Nauc_calo_1 0 22 36  Nauc_calo_2 22
0 165.8  Nauc_calo_3 36 165.8 0


The which() function with arr.ind=TRUE will identify which matrix entries meet a condition. For example,

> M <- matrix(rnorm(20), 4, 5)
> M
           [,1]       [,2]        [,3]        [,4]       [,5]
[1,] -0.6947070  1.2079620  0.77996512 -0.04287046 -1.5487528
[2,] -0.2079173 -1.1231086 -0.08336907  1.36860228  0.5846137
[3,] -1.2653964 -0.4028848  0.25331851 -0.22577099  0.1238542
[4,]  2.1689560 -0.4666554 -0.02854676  1.51647060  0.2159416
> which(M > 1.5, arr.ind=TRUE)
     row col
[1,]   4   1
[2,]   4   4

Duncan Murdoch

______________________________________________
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