View source: R/valueCoordinates.R
valueCoordinates | R Documentation |
Finds the positions (row and column indices) of values in a data.frame that match specified criteria. This function is useful for locating particular values within large datasets.
valueCoordinates(df, value = NA, eq_fun = value_check)
df |
A data.frame to search |
value |
The target value to find (default: NA) |
eq_fun |
A comparison function that takes two parameters: the current value from the data.frame and the target value. Returns TRUE for matches. Default uses internal value_check function; handles NA values. |
A data.frame with two columns:
Column indices where matches were found
Row indices where matches were found
Results are sorted by column, then by row.
# Sample data.frame
df <- data.frame(
a = c(1, NA, 3),
b = c(NA, 2, NA),
c = c(3, 2, 1)
)
# Find NA positions
valueCoordinates(df)
# Find positions of value 2
valueCoordinates(df, 2)
# Find positions where values exceed 2
valueCoordinates(df, 2, function(x, y) x > y)
# Find positions of values in range [1,3]
valueCoordinates(df, c(1, 3), function(x, y) x >= y[1] & x <= y[2])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.