[R] R Equivalent to matlab's find() command?

Stephen Eglen stephen at cogsci.ed.ac.uk
Thu Jun 8 13:53:38 CEST 2000


Just a very simple question: is there an R equivalent to the matlab
command find(X) which returns the indices of vector X that store
non-zero elements?

> find( [1 0 0 1 0])
ans =

  1  4

so, in R, how do I do:

ans <- rfind( c(1,0,0,1,0))

so that ans is the vector c(1,4)

thanks, stephen
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