R/standard_error.R

Defines functions standard_error

Documented in standard_error

#' Standard Error
#' @description This function computes the standard error of the values in x. If na.rm is TRUE then missing values are
#' removed before computation proceeds.
#' @param x a numeric vector or an R object which is coercible to one by as.double(x)
#' @param na.rm logical. Should missing values be removed?
#'
#' @return value of standard error
#' @seealso \code{\link{sd}}
#' @examples standard_error(1:7)
#' @importFrom stats na.omit var
#' @export
standard_error <- function(x, na.rm = FALSE){
  x <- as.double(x)
  return(var(x, na.rm = na.rm)/length(na.omit(x)))
}
Ronlee12355/dfbmd documentation built on Sept. 23, 2020, 10:32 a.m.