# NOT RUN {
# obtain first imputed data set
sum(is.na(nhanes2))
imp <- mice(nhanes2, print = FALSE, maxit = 1)
dat <- complete(imp)
sum(is.na(dat))
# obtain stacked third and fifth imputation
dat <- complete(imp, c(3, 5))
# obtain all datasets, with additional identifiers
head(complete(imp, "long"))
# same, but now as list, mild object
dslist <- complete(imp, "all")
length(dslist)
# same, but also include the original data
dslist <- complete(imp, "all", include = TRUE)
length(dslist)
# select original + 3 + 5, store as mild
dslist <- complete(imp, c(0, 3, 5), mild = TRUE)
names(dslist)
# }
Run the code above in your browser using DataLab