# Get the Minimum and Maximum element of a Vector in R Programming – range() Function

`range()` function in R Language is used to get the minimum and maximum values of the vector passed to it as argument.

Syntax: range(x, na.rm, finite)

Parameters:
x: Numeric Vector
na.rm: Boolean value to remove NA
finite: Boolean value to exclude non-finite elements

Example 1:

 `# R program to find the  ` `# minimum and maximum element of a vector ` ` `  `# Creating a vector ` `x <``-` `c(``8``, ``2``, ``5``, ``4``, ``9``, ``6``, ``54``, ``18``) ` ` `  `# Calling range() function ` `range``(x) `

Output:

```  2 54
```

Example 2:

 `# R program to find the  ` `# minimum and maximum element of a vector ` ` `  `# Creating a vector ` `x <``-` `c(``8``, ``2``, Inf, ``5``, ``4``, NA, ``9``, ``54``, ``18``) ` ` `  `# Calling range() function ` `range``(x) ` ` `  `# Calling range() function ` `# excluding NA values ` `range``(x, na.rm ``=` `TRUE) ` ` `  `# Calling range() function ` `# excluding finite values ` `range``(x, na.rm ``=` `TRUE, finite ``=` `TRUE) `

Output:

``` NA NA
   2 Inf
  2 54
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.