Get the Minimum and Maximum element of a Vector in R Programming – range() Function Improve Improve Like Article Like Save Share Report 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 R # 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: [1] 2 54 Example 2: Using range() Function in R programming with NA R # 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: [1] NA NA [1] 2 Inf [1] 2 54 Last Updated : 16 Dec, 2021 Like Article Save Article Previous Get the Sign of Elements of a Numeric Vector in R Programming - sign() Function Next Calculate the Mean of each Row of an Object in R Programming – rowMeans() Function Share your thoughts in the comments Add Your Comment Please Login to comment...