Learn R Programming

JWileymisc (version 0.3.1)

meanDecompose: Mean decomposition of a variable by group(s)

Description

This function decomposes a variable in a long data set by grouping factors, such as by ID.

Usage

meanDecompose(formula, data)

Arguments

formula

A formula of the variables to be used in the analysis. Should have the form: variable ~ groupingfactors.

data

A data table or data frame containing the variables used in the formula. This is a required argument.

Value

A list of data tables with the means or residuals

Examples

Run this code
# NOT RUN {
meanDecompose(mpg ~ vs, data = mtcars)
meanDecompose(mpg ~ vs + cyl, data = mtcars)

## Example plotting the results
tmp <- meanDecompose(Sepal.Length ~ Species, data = iris)
do.call(plot_grid, c(lapply(names(tmp), function(x) {
  testdistr(tmp[[x]]$X, plot = FALSE, varlab = x)$Density
}), ncol = 1))

rm(tmp)
# }

Run the code above in your browser using DataLab