rray_locate_max()finds the position of the maximum alongaxis.rray_locate_min()finds the position of the minimum alongaxis.
Value
An integer array with the same dimensionality as x, but with the dimension
along axis reduced to 1.
Details
The dimensionality of x is retained, with axis collapsed to a dimension
of 1.
Ties return the first position, like which.max() and which.min():
rray_locate_max(c(1, 3, 3), axis = 1L) # 2Missing values are infectious, so the result is NA if any value along
axis is NA or NaN. Use na_rm = TRUE to skip them:
rray_locate_max(c(1, NaN, 3), axis = 1L) # NA
rray_locate_max(c(1, NaN, 3), axis = 1L, na_rm = TRUE) # 3When there is no position to return, the result is NA. This happens when
axis has dimension 0, or when every value is missing and na_rm = TRUE:
rray_locate_max(c(NA, NA), axis = 1L, na_rm = TRUE) # NA