The function which() is widely used to check which indices in a vector satisfy certain condition.
The function which.min() is a widely used function to find the index where maximum and minimum value exists in a vector, data.frame.
The basic usage of which()
and which.min()
function is written in the exercise.
which.max
function.
# Create a variable x
x <- iris$Sepal.Length
# Logical vector
x>4
# Fix the following code to save indices where the value is larger than 4 into variable a.
a <- which(x>4)
# Access the values where x > 4.
x[a]
# Find an index where a minimum value exists.
which.min(x)
# Find an index where a maximum value exists.
which.max(x)