Learn R Programming

rbmiUtils (version 0.3.0)

create_impid: Create IMPID Column for Imputed Datasets

Description

Adds an IMPID column to a list of imputed datasets, converting them to a single stacked data.frame suitable for use with analyse_mi_data().

Usage

create_impid(imputed_list, id_prefix = "")

Value

A single data.frame with all imputed datasets stacked, with an IMPID

column identifying the source imputation.

Arguments

imputed_list

A list of data.frames, where each element represents one imputed dataset.

id_prefix

Optional character prefix for IMPID values. Default is empty string.

Details

This function is useful when you have imputed datasets from a source other than rbmi (e.g., from mice or another MI package) and want to use them with rbmiUtils analysis functions.

See Also

  • get_imputed_data() to extract imputed data from rbmi objects

  • analyse_mi_data() to analyse stacked imputed data

Examples

Run this code
# Create example imputed datasets
imp1 <- data.frame(USUBJID = c("S1", "S2"), CHG = c(1.5, 2.5))
imp2 <- data.frame(USUBJID = c("S1", "S2"), CHG = c(1.8, 2.2))
imp3 <- data.frame(USUBJID = c("S1", "S2"), CHG = c(1.6, 2.4))

# Stack with IMPID
stacked <- create_impid(list(imp1, imp2, imp3))
print(stacked)

Run the code above in your browser using DataLab