stack_imputations: Stack Multiply Imputed Datasets

View source: R/utils.R

stack_imputationsR Documentation

Stack Multiply Imputed Datasets

Description

Concatenates a list of imputed data frames into a single stacked data frame. An imputation-index column (.imp) is added to identify which imputed dataset each row originated from.

Usage

stack_imputations(data_list, imp_col = ".imp")

Arguments

data_list

A list of data frames, all with the same dimensions and column names, representing M imputed versions of the same dataset.

imp_col

Character string. Name of the imputation-index column added to the stacked data (default ".imp"). Set to NULL to suppress the column.

Value

A single data frame with M \times n rows, where n is the number of rows in each imputed dataset. If imp_col is not NULL, an integer column recording the imputation index is appended.

References

Sherlock, P., Mansolf, M., Hofheimer, J., Hockett, C. W., O'Connor, T. G., Roubinov, D., Graff, J. C., Lai, J.-S., Bush, N. R., Wright, R. J., & Chiu, Y.-H. M. (2026). Beyond linear risk: A machine learning approach to understanding perinatal depression in context. Multivariate Behavioral Research, 1–16. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00273171.2026.2661244")}

Rodgers, J., Khoo, S.-T., & Ludtke, O. (2021). Handling missing data in structural equation models using multiple imputation and stacking. Structural Equation Modeling, 28(6), 915–930.

See Also

ctree_stacked, rescale_alpha

Examples

df1 <- data.frame(x = 1:5, y = c(2, 4, 6, 8, 10))
df2 <- data.frame(x = 1:5, y = c(2, 3, 6, 9, 10))
df3 <- data.frame(x = 1:5, y = c(1, 4, 5, 8, 11))

stacked <- stack_imputations(list(df1, df2, df3))
nrow(stacked)           # 15
table(stacked$.imp)     # 5 rows per imputation

ctreeMI documentation built on July 26, 2026, 1:06 a.m.