[R] find indices of nonzero elements
David A Richmond
richmond at saintmarys.edu
Tue Oct 9 04:56:42 CEST 2001
Hi,
Is there a function func(x) where x is an array such that it
returns a list of the indices of all non-zero elements of the array?
for example:
a:
1 0 0
0 0 1
0 1 0
func(a) returns two vectors r and c:
r c
1 1
2 3
3 2
daver
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|David Richmond It works on a |
+ Dept. of Sociology complex scientific +
|Saint Mary's College principle, known as |
+ Notre Dame, IN 46556 "pot luck." +
|219-284-4517 - The Doctor |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list