https://github.com/cran/pracma
Tip revision: 7f8c12bb73c64627d031ab960efe5639f33d0069 authored by Hans W. Borchers on 11 July 2015, 00:00:00 UTC
version 1.8.6
version 1.8.6
Tip revision: 7f8c12b
std.R
##
## s t d . R
##
std <- function(x, flag=0) {
if (length(x) == 0) return(c())
if (!is.numeric(x))
stop("Argument 'x' must be a numeric vector or matrix.")
n <- if (flag == 0) length(x) - 1 else length(x)
sqrt(sum((x-mean(x))*(x-mean(x)))/n)
}
std_err <- function(x) {
if (length(x) == 0) return(c())
if (!is.numeric(x))
stop("Argument 'x' must be a numeric vector or matrix.")
sqrt(var(x)/length(x))
}