calcstatdif: Differences of Basic Descriptive Statistics

View source: R/calcstatdif.R

calcstatdifR Documentation

Differences of Basic Descriptive Statistics

Description

Calculates the differences in multiple statistics (mean, median, IQR, variance) for grouped data.

Usage

calcstatdif(x, indices, ...)

Arguments

x

A data frame or matrix containing the input data. The first column should be the variable of interest, and the second column should be the grouping variable.

indices

Optional; specific rows to be considered. If not provided, all rows are used.

...

Optional arguments;

Details

This function calculates the differences in multiple statistics (mean, median, interquartile range (IQR), and variance) for groups defined by the second column of the input data. The function is used in permutation test and bootstrapping as a statistical function.

Value

A named numeric vector containing the differences in the specified statistics for each group. The names of the vector elements are "MEAN", "MED", "IQR", "VAR", "SKEW", and "KURT" for mean, median, interquartile range, variance, skewness, and kurtosis, respectively.

Author(s)

Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe

See Also

calcquantdif

Examples

# Generate example data 
set.seed(1199)  
grp1 <- rnorm(20, 45, 5)
grp2 <- c(rnorm(10, 45, 10), rnorm(10, 52, 20))
df <- data.frame(cbind(grp1=grp1, grp2=grp2))
head(df)
bivarplot(df)

# Reshape the data into long format
df <- wide2long(df)
head(df)

# Differences between the basic stats
calcstatdif(df)

groupcompare documentation built on June 26, 2025, 1:08 a.m.