This handles type casting and missing placeholder value selection/substitution. It is primarily intended for developers of alabaster.* extensions.

transformVectorForHdf5(x, .version = 3)

Arguments

x

An atomic vector to be saved to HDF5.

.version

Internal use only.

Value

A list containing:

  • transformed, the transformed vector. This may be the same as x if no NA values were detected. Note that logical vectors are cast to integers.

  • placeholder, the placeholder value used to represent NA values. This is NULL if no NA values were detected in x, otherwise it is the same as the output of chooseMissingPlaceholderForHdf5.

Author

Aaron Lun

Examples

transformVectorForHdf5(c(TRUE, NA, FALSE))
#> $transformed
#> [1]  1 -1  0
#> 
#> $placeholder
#> [1] -1
#> 
transformVectorForHdf5(c(1L, NA, 2L))
#> $transformed
#> [1]  1 NA  2
#> 
#> $placeholder
#> [1] NA
#> 
transformVectorForHdf5(c(1L, NaN, 2L))
#> $transformed
#> [1]   1 NaN   2
#> 
#> $placeholder
#> NULL
#> 
transformVectorForHdf5(c("FOO", NA, "BAR"))
#> $transformed
#> [1] "FOO" "NA"  "BAR"
#> 
#> $placeholder
#> [1] "NA"
#> 
transformVectorForHdf5(c("FOO", NA, "NA"))
#> $transformed
#> [1] "FOO" "_NA" "NA" 
#> 
#> $placeholder
#> [1] "_NA"
#>