2020-03-18 10:30:37 +01:00
|
|
|
#' @title Find indices and values of nonzero elements
|
|
|
|
|
#' @description Emulates behavior of `find`
|
2020-03-18 15:02:38 +01:00
|
|
|
#' @param x object or logic operation on an object
|
2020-03-18 10:30:37 +01:00
|
|
|
find <- function(x) {
|
|
|
|
|
if (is.logical(x)) {
|
|
|
|
|
return(which(x))
|
|
|
|
|
} else {
|
|
|
|
|
return(which(x > 0))
|
|
|
|
|
}
|
|
|
|
|
}
|