R/chooseMissingPlaceholderForHdf5.R
chooseMissingPlaceholderForHdf5.Rd
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)
A placeholder value for missing values in x
,
guaranteed to not be equal to any non-missing value in x
.
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
.
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