I\'m using a data set where the 11th column on a csv file has numeric data. It contains some NA values too. Here is the str of the object:
str(dataheart)
num [1
You need
range(x,na.rm=TRUE)
see ?range
For extra credit, here's a list of the functions in the base
and stats
packages that use na.rm
:
uses_na_rm <- function(x) is.function(fx <- get(x)) &&
"na.rm" %in% names(formals(fx))
basevals <- ls(pos="package:base")
basevals[sapply(basevals,uses_na_rm)]
## [1] "colMeans" "colSums"
## [3] "is.unsorted" "mean.default"
## [5] "pmax" "pmax.int"
## [7] "pmin" "pmin.int"
## [9] "range.default" "rowMeans"
## [11] "rowsum.data.frame" "rowsum.default"
## [13] "rowSums" "Summary.data.frame"
## [15] "Summary.Date" "Summary.difftime"
## [17] "Summary.factor" "Summary.numeric_version"
## [19] "Summary.ordered" "Summary.POSIXct"
## [21] "Summary.POSIXlt"
statvals <- ls(pos="package:stats")
statvals[sapply(statvals,uses_na_rm)]
## [1] "density.default" "fivenum" "heatmap" "IQR"
## [5] "mad" "median" "median.default" "medpolish"
## [9] "quantile.default" "sd" "var"
For further consideration of which functions in R deal with NA
s and how, one could do an analogous search for functions with an na.action
argument (lm
and friends).