View source: R/com_qualified_item_missingness.R
com_qualified_item_missingness | R Documentation |
Indicator
com_qualified_item_missingness(
resp_vars,
study_data,
meta_data,
label_col = NULL,
expected_observations = c("HIERARCHY", "ALL", "SEGMENT")
)
resp_vars |
variable list the name of the measurement variables |
study_data |
data.frame the data frame that contains the measurements |
meta_data |
data.frame the data frame that contains metadata attributes of study data |
label_col |
variable attribute the name of the column in the metadata with labels of variables |
expected_observations |
enum HIERARCHY | ALL | SEGMENT. Report the
number of observations expected using
the old |
list list with entries:
## Not run:
prep_load_workbook_like_file("inst/extdata/Metadata_example_v3-6.xlsx")
clean <- prep_get_data_frame("item_level")
clean <- subset(clean, `Metadata name` == "Example" &
!dataquieR:::util_empty(VAR_NAMES))
clean$`Metadata name` <- NULL
clean[, "MISSING_LIST_TABLE"] <- "missing_matchtable1"
prep_add_data_frames(item_level = clean)
clean <- prep_get_data_frame("missing_matchtable1")
clean <- clean[clean$`Metadata name` == "Example", , FALSE]
clean <-
clean[suppressWarnings(as.character(as.integer(clean$CODE_VALUE)) ==
as.character(clean$CODE_VALUE)), , FALSE]
clean$CODE_VALUE <- as.integer(clean$CODE_VALUE)
clean <- clean[!is.na(clean$`Metadata name`), , FALSE]
clean$`Metadata name` <- NULL
prep_add_data_frames(missing_matchtable1 = clean)
ship <- prep_get_data_frame("ship")
number_of_mis <- ceiling(nrow(ship) / 20)
resp_vars <- sample(colnames(ship), ceiling(ncol(ship) / 20), FALSE)
mistab <- prep_get_data_frame("missing_matchtable1")
valid_replacement_codes <-
mistab[mistab$CODE_INTERPRET != "I", "CODE_VALUE",
drop =
TRUE] # sample only replacement codes on item level. I uses the actual
# values
for (rv in resp_vars) {
values <- sample(as.numeric(valid_replacement_codes), number_of_mis,
replace = TRUE)
if (inherits(ship[[rv]], "POSIXct")) {
values <- as.POSIXct(values, origin = min(as.POSIXct(Sys.Date()), 0))
}
ship[sample(seq_len(nrow(ship)), number_of_mis, replace = FALSE), rv] <-
values
}
com_qualified_item_missingness(resp_vars = NULL, ship, "item_level", LABEL)
com_qualified_item_missingness(resp_vars = "Diabetes Age onset", ship,
"item_level", LABEL)
com_qualified_item_missingness(resp_vars = NULL, "study_data", "meta_data",
LABEL)
study_data <- ship
meta_data <- prep_get_data_frame("item_level")
label <- LABEL
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.