which() 、 which.min() 、 which.max() 函数

Which function () can be used to find the subscripts satisfy the conditions, such as

x <- c(3, 4, 3, 5, 7, 5, 9)
which(x > 5)

5 7

  

seq(along=x)[x > 5]

5 7

Here seq (along = x) is generated by the subscript x is a vector consisting of

With which.min (),
which.max find the superscripts minimum and maximum, are not unique only take the first. Such as

which.min(x)
1

which.max(x)
7

  

Guess you like

Origin www.cnblogs.com/jiaxinwei/p/12342992.html