Some the downstream uses of a FacileDataStore can throw problems when NA's are found in data 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(
  data,
  replace = list(),
  defaults = list(),
  ignore = character(),
  ...
)

Arguments

data

the thing that has NA's in it (a data.frame or vector)

replace

a named list of elements to use for custom replacement values

defaults

if named elements in data do not appear in replace, you can provide default values for categories of parameters (ie. "categorical" or "numeric"), otherwise FacileData:::defaults.freplace_na will be used.

Value

an NA-replaced version of data

Details

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 FacileDataStores since we often use them to include data from multiple datasets, which induces "ragged" (sparse) covariate (pData) entries. In man

Examples

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))