| observed_data | R Documentation |
Sets every cell the mask flags to NA, leaving the complete data otherwise
untouched, and keeps the mask alongside the result as a tidy component.
observed_data(data, missingness, id = NULL)
data |
Complete base |
missingness |
A logical mask returned by |
id |
Identifier columns the mask carries that are never made missing. A
character vector, or |
A simulab_sim base data.frame with the columns and rows of
data, the flagged cells of the target variables replaced by NA. The
component missingness, reached with
as.data.frame(x, what = "missingness"), is the mask in long form, one row
per observation and target variable, with columns observation, variable
and the logical missing.
data <- data.frame(id = 1:100, outcome = stats::rnorm(100))
mask <- missingness_matrix(
data,
specification = define_missingnesses(define_missingness("outcome", formula = "0.3")),
seed = 1
)
result <- observed_data(data, missingness = mask, id = "id")
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.