R/skewness.r

Defines functions skewness

Documented in skewness

#' Skewness Statistic
#'
#' Calculates the skewness statistic of the data in 'x'. Values close to zero
#' correspond to reasonably symmetric data, positive values of this measure
#' indicate right-skewed data whereas negative values indicate left-skewness.
#'
#' @param x vector containing the data.
#' @param \dots any other variables to be passed to \code{mean} and \code{sd}, e.g.
#' \code{na.rm = TRUE}.
#' @return Returns the value of the skewness.
#' @keywords univar
#' @examples
#'
#' ## Merger data:
#' data(mergers.df)
#' skewness(mergers.df$mergerdays)
#'
#' @export skewness
skewness = function(x, ...) {
  meanValue = mean(x, ...)
  sdValue = sd(x, ...)

  mean((x - meanValue)^3, ...) / sdValue^3
}

Try the s20x package in your browser

Any scripts or data that you put into this service are public.

s20x documentation built on July 1, 2026, 9:06 a.m.