To find the range of all elements in an array in R, you can use the range()
function which returns a vector of the minimum and maximum values of the input data.
main.r152 chars6 lines
The output will be a vector with the minimum and maximum values of the array:
[1] 2 12
Alternatively, you can also use the min()
and max()
functions to find the minimum and maximum values, and then calculate the range by subtracting the minimum from the maximum:
main.r104 chars7 lines
This will also give you the range of all elements in the array:
[1] 10
gistlibby LogSnag