freplace_na | R Documentation |
Some the downstream uses of a FacilexStore can throw problems when NA's
are found in x or covariates, so we often want to fill in NA's with
non-NA markers of missing values. Note that unless specified otherwise
(using the replace
and defaults
parameters),
freplace_na(x, replace = list(), defaults = list(), ignore = character(), ...)
x |
the thing that has NA's in it (a data.frame, list, or vector) |
replace |
a named list of elements to use for custom replacement values |
defaults |
if named elements in |
ignore |
the names of columns (or elements in a list) |
Depending on the atomic type of the thing that NA's are being replaced with,
a default value is assumed. These can be overriden by using the defaults
parameter, or specifically by column (or list) names via the replace
parameter.
Missing values (NA's) come up often in FacilexStores since we often use them to include x from multiple xsets, which induces "ragged" (sparse) covariate (px) entries. In man
an data-replaced version of x
data <- data.frame(
a = rnorm(10),
b = letters[1:10],
c = factor(LETTERS[1:10]))
data[3, ] <- NA
r1 <- freplace_na(data, list(b = "bee"), ignore = "a")
r2 <- freplace_na(data, list(b = "bee"), defaults = list(numeric = -Inf))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.