Description Usage Arguments Details Value See Also Examples
View source: R/grandMeanFunction4.R
Create a "grand mean" data set from a series of imputed data sets
1 2 3 4 5 6 7 |
stackedData |
a data.frame of several stacked imputed data sets |
idName |
a character vector of length 1 providing the name of the imputation id variable. |
contNames |
a character vector providing the names of the continuous variables. Default is NULL. |
discNames |
a character vector providing the names of the discrete variables. Default is NULL. |
dropNames |
a character vector providing the names of the variables to be excluded from the operation. Default is NULL. |
This function is an extension of the aggregate
function for imputed data sets that contain multiple variable types. The default behavior is to aggregate the continuous variables inferred from contNames
using the arithmetic mean, and to aggregate the discrete variables inferred from discNames
using mode, while the variables inferred from dropNames
are removed.
a data.frame with the number of columns equal to stackedData
and the number of rows equal to the unique values in the id column.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Create example data
data(iris)
iris$id <- factor(1:nrow(iris))
irisStack <- do.call(rbind, rep(list(iris), 10))
irisStack$junk <- sample(1:2000, nrow(iris))
## Create name vectors
irisContNames <- names(which(sapply(iris, is.numeric)))
irisDiscNames <- "Species"
irisDropNames <- "junk"
irisIdName <- "id"
## Create grand mean
gm <- grandMean(
stackedData = irisStack,
idName = irisIdName,
contNames = irisContNames,
discNames = irisDiscNames,
dropNames = irisDropNames
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.