VOOZH about

URL: https://www.geeksforgeeks.org/r-language/get-the-minimum-and-maximum-element-of-a-vector-in-r-programming-range-function/

⇱ Get the Minimum and Maximum element of a Vector in R Programming - range() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

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

Last Updated : 15 Jul, 2025

range() function in R Programming Language is used to get the minimum and maximum values of the vector passed to it as an 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

R - range() Function Examples

Example 1: Get the Minimum and Maximum element of a Vector using range() Function in R language

Output: 

[1] 2 54

Example 2: Using range() Function in R programming with NA 

Output: 

[1] NA NA
[1] 2 Inf
[1] 2 54
Comment
Article Tags:

Explore