Return the Index of the First Minimum Value of a Numeric Vector in R Programming – which.min() Function

function in R Language is used to return the location of the first minimum value in the Numeric Vector.**which.min()**

Syntax:which.min(x)

Parameters:x:Numeric Vector

**Example 1:**

`# R program to find index of` `# first minimum value` ` ` `# Creating a vector` `x <` `-` `c(` `2` `, ` `3` `, ` `4` `, ` `5` `, ` `1` `, ` `2` `, ` `3` `, ` `1` `, ` `2` `)` ` ` `# Calling which.min() function` `which.` `min` `(x)` ` ` `# Printing minimum value` `x[which.` `min` `(x)]` |

**Output:**

[1] 5 [1] 1

**Example 2:**

`# R program to find index of` `# first minimum value` ` ` `# Calling pre-defined dataset` `BOD$demand` ` ` `# Calling which.min() function` `which.` `min` `(BOD$demand)` ` ` `# Printing minimum value` `BOD$demand[which.` `min` `(BOD$demand)]` |

**Output:**

[1] 8.3 10.3 19.0 16.0 15.6 19.8 [1] 1 [1] 8.3