range()
function get a vector of the minimum and maximum values.
range(..., na.rm = FALSE, finite = FALSE)
...
: numeric vectorna.rm
: whether NA should be removed, if not, NA will be returnedfinite
: whether non-finite elements should be omitted>x <- c(1,2.3,2,3,4,8,12,43,-4,-1) >r <- range(x) >r
[1] -4 43
>diff(r)
[1] 47
>y<- c(x,NA) >y
[1] 1.0 2.3 2.0 3.0 4.0 8.0 12.0 43.0 -4.0 -1.0 NA
>range(y)
[1] NA NA
>range(y,na.rm=TRUE)
[1] -4 43
> range(y,finite=TRUE)
[1] -4 43