https://github.com/cran/fields
Tip revision: 6c8b30169bba182a68765ee3cb9b4e2ef7d38332 authored by Doug Nychka on 16 November 2011, 00:00:00 UTC
version 6.6.3
version 6.6.3
Tip revision: 6c8b301
describe.r
# fields, Tools for spatial data
# Copyright 2004-2011, Institute for Mathematics Applied Geosciences
# University Corporation for Atmospheric Research
# Licensed under the GPL -- www.gpl.org/licenses/gpl.html
"describe" <- function(x) {
lab <- c("N", "mean", "Std.Dev.", "min", "Q1", "median",
"Q3", "max", "missing values")
if (missing(x)) {
return(lab)
}
temp <- rep(0, length(lab))
xt <- x[!is.na(x)]
ix <- order(xt)
n <- length(xt)
if (!is.numeric(xt) || all(is.na(x))) {
return(c(n, rep(NA, length(lab) - 2), length(x) - length(xt)))
}
if (n == 1) {
return(c(n, xt[1], NA, rep(xt[1], 5), length(x) - length(xt)))
}
else {
return(c(n, mean(xt), sqrt(var(xt)), min(xt), quantile(xt,
c(0.25, 0.5, 0.75)), max(xt), length(x) - length(xt)))
}
}