What is the purpose of the which() function in the context of logical vectors in R?

  • It returns the indices of the elements that are TRUE
  • It returns the count of the elements that are TRUE
  • It returns the logical complement of the input vector
  • It returns the values of the elements that are TRUE
In the context of logical vectors in R, the which() function is used to return the indices of the elements that are TRUE. For example, which(c(TRUE, FALSE, TRUE)) would return the indices 1 and 3.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *