meanDecompose {multilevelTools} | R Documentation |
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. If multiple grouping factors are listed, the decomposition is in order from left to right. Residuals from the lowest level are returned.
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
meanDecompose(mpg ~ vs, data = mtcars)
meanDecompose(mpg ~ vs + cyl, data = mtcars)
## Example plotting the results
tmp <- meanDecompose(Sepal.Length ~ Species, data = iris)
do.call(cowplot::plot_grid, c(lapply(names(tmp), function(x) {
plot(JWileymisc::testDistribution(tmp[[x]]$X), plot = FALSE, varlab = x)$Density
}), ncol = 1))
rm(tmp)
[Package multilevelTools version 0.1.1 Index]