To find the range in R, you can use two different function range() function or difference between minimum and maximum value of dataset.

The following methods show how you can do it with syntax.

Method 1: Use range() Function

range(data)

Method 2: Use min() and max() Function

max(data) - min(data)

The following examples show to find range in R using different functions.

Using range() Function

Let’s see how we can use range() function to find range in R:

# Create dataset
data <- c(78,89,85,84,81,79,77,85,85,81,78,89,84,84,81,80)

# Find range
range(data)

Output:

[1] 77 89

Here the output shows minimum and maximum value for range.

Using min() and max() Function

Let’s see how we can use min() and max() function to find range in R:

# Create dataset
data <- c(78,89,85,84,81,79,77,85,85,81,78,89,84,84,81,80)

# Find range
range_ <- max(data) - min(data)

# Show range
print(range_)
[1] 12

Here the output shows difference between minimum and maximum value.