R/rootMedianSquare.R

Defines functions rootMedianSquare

Documented in rootMedianSquare

#'
#'@title Compute the root median square deviation (rmsd) of a vector 
#'
#'@description Function to compute the root median square deviation (rmsd) of a vector.
#'
#'@param y - vector to compute rmsd for
#'@param na.rm - flag to remove NAs before calculating
#'
#'@return the rmsd, or NA_real_ if y is all NAs 
#'
#'@details Uses package \code{stats}.
#'
#'@export
#'
rootMedianSquare<-function(y,na.rm=TRUE){
  x<-y-stats::median(y,na.rm=na.rm);
  if (length(x)>0) return(sqrt(sum(x*x)/length(x)));
  return(NA_real_);
}
wStockhausen/wtsUtilities documentation built on March 16, 2024, 10:38 a.m.