r函数返回布尔值,其中哪个元素是最大的
我需要一个布尔值,告诉我向量的元素是否是该向量的最大值。应该返回这样的东西
vec <- c(3,4,1,5)
maxBoolFunct(vec)
[1] FALSE FALSE FALSE TRUE
max()
只会告诉我最大值实际是什么,whe.max
简单地给了我向量中的位置。我需要一个布尔人。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用逻辑索引。
You can use logical indexing.