R/sem_func.R

Defines functions sem_func

Documented in sem_func

#' Standard Error of the Mean (SEM)
#'
#' @param x A numeric vector.
#' @param na.rm Boolean. Should the NA values be removed? defoult to FALSE.
#'
#' @return The SEM from a given vector
#' @export
#'
#' @examples
#' x <- c(0:10)
#' sem_x <- sem_func(x)
#'
sem_func <- function(x, na.rm=FALSE) {
  if (na.rm) x <- stats::na.omit(x)
  sqrt(stats::var(x)/length(x))
}
rjlopez2/AnlysisOfWaves documentation built on Sept. 15, 2022, 2:25 p.m.