The range()
function in R is used to return a vector with two elements:
The range()
function takes the syntax below:
range(…, na.rm = FALSE)
The range()
function takes the following parameter values:
...
: This represents any numeric or character objects or vectors.na.rm
: This takes a Boolean value (TRUE
or FALSE
) indicating if the NaN
(Not a Number) values should be omitted or not.The range()
function returns a vector object holding the result.
# creating an input vector objecta <- c(1, 2, 3, 4, 10, NaN)# calling the range() functionrange(a, na.rm=TRUE)
a
.range()
function on the object. We print the result to the console.