Learn R Programming

miceadds (version 1.5-0)

fast.groupmean: Calculation of Groupwise Descriptive Statistics for Matrices

Description

Calculates some groupwise descriptive statistics

Usage

fast.groupmean(data, group, weights=NULL, extend=FALSE)

fast.groupsum(data, group, weights=NULL, extend=FALSE)

Arguments

data
A numeric data frame
group
A vector of group identifiers
weights
An optional vector of sample weights
extend
Optional logical indicating whether the group means (or sums) should be extended to the original dimensions of the dataset.

Value

  • A data frame with groupwise calculated statistics

Examples

Run this code
#############################################################################
# EXAMPLE 1: Group means data.ma02
#############################################################################

data( data.ma02 )
dat <- data.ma02[[1]] # select first dataset

# group means for read and math
fast.groupmean( dat[ , c("read","math") ] , group=dat$idschool )


# extend group means to original dataset
fast.groupmean( dat[ , c("read","math") ] , group=dat$idschool , extend =TRUE )

Run the code above in your browser using DataLab