Skip to contents

This function finds the coordinates (row and column indices) of a specific value in an object. If no value is provided, it finds the coordinates of NA values.

Usage

valueCoordinates(obj, value = NA)

Arguments

obj

The object to find the value in. Should be a matrix or data frame.

value

The value to find in the object. Default is NA.

Value

A data frame with the column and row indices of the value in the object.

Examples

mat <- matrix(1:9, nrow = 3)
mat[2, 2] <- NA
valueCoordinates(mat)
#>    column   row
#>     <int> <int>
#> 1:      2     2
# Returns a data frame with the coordinates of NA
valueCoordinates(mat, 5)
#> Empty data.table (0 rows and 2 cols): column,row
# Returns a data frame with the coordinates of the value 5