# Create a toy dataset with missing values
X <- data.frame(
cont = c(NA, 5, NA, NA, NA, NA), # Subj 1: Gap/Lead/Trail, Subj 2: All NA
bin = c(0, NA, 1, 1, 1, 0) # Subj 1: Gap, Subj 2: Complete
)
subject_id <- c(1, 1, 1, 2, 2, 2)
is_binary <- c(FALSE, TRUE)
# Run imputation
X_imputed <- apply_locf_nocb(X, subject_id, is_binary)
Run the code above in your browser using DataLab