Learn R Programming

groupcompare (version 1.0.1)

calcstatdif: Differences of Basic Descriptive Statistics

Description

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

Usage

calcstatdif(x, indices, ...)

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.

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;

Author

Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe

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.

See Also

calcquantdif

Examples

Run this code
# 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)

Run the code above in your browser using DataLab