expand.mat: Utility function to expand aggregated data

View source: R/expand.mat.R

expand.matR Documentation

Utility function to expand aggregated data

Description

The function expands aggregated data into casewise data. For instance, for a contingency table given in the form of a design matrix and corresponding counts the function sets up a matrix where each design row is repeated according to the frequencies for that row.

Usage

expand.mat(mat, freq)

Arguments

mat

a matrix (or column vector) or data frame to be expanded

freq

a vector of counts

Value

the expanded matrix.

Note

This utility allows to generate input data for the design generating and model fitting functions of the prefmod package from aggregated data.

Examples

tdat <- expand.mat(tennis[, -1], tennis[, 1])
head(tdat)

prefmod documentation built on Sept. 30, 2023, 5:06 p.m.