which0: Matrix Which Function

View source: R/RcppExports.R

which0R Documentation

Matrix Which Function

Description

Matrix Which Function

Usage

which0(X, f)

Arguments

X

A matrix

f

A predicate to apply to each element of X.

Details

The which C++ functions are intended to operate like the following call in R.

which(f(X), arr.ind = TRUE) - 1

The R functions exposed here are specific to numeric-valued matrices, but the underlying C++ functions are intended to work with any type of Rcpp Matrix.

Value

A matrix with two columns. Each row contains a row and column index corresponding to an element of X that matches the criteria of f. See section "Which" of the package vignette for details.

Examples

X = matrix(1:12 / 6, nrow = 4, ncol = 3)
f = function(x) { x < 1 }
which0(X, f)


fntl documentation built on April 4, 2025, 1:53 a.m.