Revision 03698027c2d84118bd0c53c4a9a5b5d23676f388 authored by HwB on 01 October 2012, 00:00:00 UTC, committed by Gabor Csardi on 01 October 2012, 00:00:00 UTC
1 parent 9fdea5d
Raw File
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))
}
back to top