Learn R Programming

matlab2r (version 1.5.0)

find: Find indices and values of nonzero elements

Description

Emulates behavior of find

Usage

find(x, sort = TRUE)

Value

A vector of indices of x that satisfy the logical test (nonzero, by default).

Arguments

x

object or logic operation on an object

sort

sort output?

Examples

Run this code
X <- matrix(c(1, 0, 2, 0, 1, 1, 0, 0, 4), 3, byrow = TRUE)
Y <- seq(1, 19, 2)
find(X)
find(Y == 13)

Run the code above in your browser using DataLab