In the alabaster.* framework, we mark missing entries inside HDF5 datasets with placeholder values. This function chooses a value for the placeholder that does not overlap with anything else in a vector.

chooseMissingPlaceholderForHdf5(x, .version = 3)

Arguments

x

An atomic vector to be saved to HDF5.

.version

Internal use only.

Value

A placeholder value for missing values in x, guaranteed to not be equal to any non-missing value in x.

Details

For floating-point datasets, the placeholder will not be NA if there are mixtures of NAs and NaNs. We do not rely on the NaN payload to distinguish between these two values.

Placeholder values are typically saved as scalar attributes on the HDF5 dataset that they are used in. The usual name of this attribute is "missing-value-placeholder", as encoding by missingPlaceholderName.

Examples

chooseMissingPlaceholderForHdf5(c(TRUE, NA, FALSE))
#> [1] -1
chooseMissingPlaceholderForHdf5(c(1L, NA, 2L))
#> [1] NA
chooseMissingPlaceholderForHdf5(c("aaron", NA, "barry"))
#> [1] "NA"
chooseMissingPlaceholderForHdf5(c("aaron", NA, "barry", "NA"))
#> [1] "_NA"
chooseMissingPlaceholderForHdf5(c(1.5, NA, 2.6))
#> [1] NA
chooseMissingPlaceholderForHdf5(c(1.5, NaN, NA, 2.6))
#> [1] Inf