vim_complete: Extract completed datasets from a vimmi object

View source: R/vimmi.R

vim_completeR Documentation

Extract completed datasets from a vimmi object

Description

Reconstructs one or more completed datasets by filling in imputed values from the specified imputation(s).

Usage

vim_complete(data, action = 1, ...)

## S3 method for class 'vimmi'
complete(data, action = 1, ...)

Arguments

data

A vimmi object (produced by vimpute with m > 1)

action

Specifies which completed dataset(s) to return:

  • Integer (1..m): return a single completed data.frame for that imputation

  • "all": return a named list of all m completed data.frames

  • "long": return a single data.frame in long format with .imp (imputation number) and .id (row number) columns

...

Currently unused

Details

vim_complete() is the documented name and always works. The same function is additionally registered as an S3 method on mice::complete() and tidyr::complete(), so if either package is attached the familiar complete(result, 1) dispatches to it.

VIM deliberately does not export a complete() generic of its own. Both mice and tidyr export a generic of that name, so an exported VIM generic would mask them (and be masked by them), and would make any package that imports VIM and one of those packages wholesale emit “replacing previous import” at load time. Registering the method on the foreign generics gives the same user-facing call without the clash – the same approach VIM takes for vim_as_mids.

Value

A data.frame, list of data.frames, or long-format data.frame

Examples

## Not run: 
result <- vimpute(sleep, method = "ranger", m = 5, boot = TRUE, uncert = "normalerror")
d1 <- vim_complete(result, 1)        # first completed dataset
all_d <- vim_complete(result, "all")  # list of 5 datasets
long_d <- vim_complete(result, "long") # long format with .imp column

# With mice or tidyr attached, the generic dispatches to the same function:
# library(mice); d1 <- complete(result, 1)

## End(Not run)

VIM documentation built on Sept. 2, 2026, 5:07 p.m.