whichRowCol | R Documentation |
Identifies the row and column numbers (indexes) of TRUE
values in a
logical matrix.
whichRowCol(x, which = "both")
x |
a logical matrix. Missing values are treated as |
which |
a character string indicating what should be returned. |
A matrix of the row and column number if which
is "both."
Otherwise a named vector of the row number, if which
is "row," or
column number, if which
is "col." Only the first character is needed.
Some comparisons, %in%
for example, will return a vector rather
than a matrix and cause whichRowCol to fail.
row
, col
, which
# Simple case to find a single value whichRowCol(matrix(1:20, ncol=4) == 16) # Where are the missing values in a data set? library(smwrData) data(MenomineeMajorIons) whichRowCol(sapply(MenomineeMajorIons, is.na))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.