The “which.min” Function in R

  • Package: Base R (no specific package required)

  • Purpose: Identifies the index of the first minimum value in a numeric vector.

  • General Class: Indexing

  • Required Argument(s):

    • x: A numeric vector.

  • Notable Optional Arguments:

    • None

  • Example:

  • # Example data for using the which.min function
    numeric_vector <- c(3, 8, 2, 10, 5)

    # Use which.min to find the index of the first minimum value
    min_index <- which.min(numeric_vector)

    # Display the result
    print(min_index)

  • In this example, the which.min function is used to find the index of the first minimum value in a numeric vector (numeric_vector). The resulting index (min_index) corresponds to the position of the first occurrence of the minimum value in the vector. The which.min function is commonly used when you need to locate the index of the minimum value in a numeric vector.

Previous
Previous

The “write.xlsx” Function in R

Next
Next

The “which.max” Function in R