View source: R/api-estimation.R
| recode_missing_codes | R Documentation |
NAConvenience helper that replaces the standard non-NA missing-code
sentinels used in SPSS / SAS / FACETS exports (99, 999, -1,
"N", "NA", "n/a", ".", "") with NA across the columns
you select. This is the R counterpart of the preprocessing UI in
the companion Streamlit app and is useful before calling
fit_mfrm() on data exported with those conventions.
recode_missing_codes(
data,
columns = NULL,
codes = c("99", "999", "-1", "N", "NA", "n/a", ".", ""),
numeric_codes = TRUE,
verbose = FALSE
)
data |
A data frame. |
columns |
Character vector of column names to recode. Defaults
to |
codes |
Character vector of code values to convert to |
numeric_codes |
Logical; if |
verbose |
Logical; if |
The input data with the specified missing sentinels
replaced by NA. A mfrm_missing_recoding attribute records the
per-column replacement counts for traceability logs.
describe_mfrm_data(), fit_mfrm().
dat <- data.frame(
Person = paste0("P", 1:5),
Rater = c("R1", "R1", "R2", "R2", "R2"),
Score = c(1, 99, 2, -1, 3)
)
cleaned <- recode_missing_codes(dat, columns = "Score")
cleaned$Score
attr(cleaned, "mfrm_missing_recoding")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.