I need a boolean that tells me whether an element of a vector is that vector's maximum. Should return something like this
vec <- c(3,4,1,5)
maxBoolFunct(vec)
[1] FALSE FALSE FALSE TRUE
max()
just tells me what the maximum value actually is and which.max
simply gives me the position in the vector. I need a boolean.
CodePudding user response:
You can use logical indexing.
> vec = c(3,4,1,5)
> vec == max(vec)
[1] FALSE FALSE FALSE TRUE