Add integer64 support
This package is awesome - tabular data stored as plain text with saved column types.
The integer64 format is provided by the bit64 R package. It would be nice to include support for it in this package.
mtcars2 <- mtcars |> dplyr::mutate(cyl = bit64::as.integer64(cyl))
git2rdata::write_vc(mtcars2, file = "mtcars2") # This currently returns an error
The error is
Error in UseMethod("meta", x) no applicable method for 'meta' applied to an object of class "integer64"
R: 4.4.3 git2rdata: 0.5.0
A solution with the current version would be to convert the integer64 variable to a character string before writing and converting is back after writing.
Adding native support for integer64 would increase the number of dependencies to git2rdata, making it harder to maintain the package. What about an argument which would allow to do the conversions on the fly?
mtcars2 <- mtcars |> dplyr::mutate(cyl = bit64::as.integer64(cyl))
git2rdata::write_vc(
mtcars2, file = "mtcars2",
convert = list(cyl = c(write = "bit64::as.character", read = "bit64::as.integer64")
)
That would be great!
Would it save this convert argument in the yaml metadata? That would be ideal, maybe difficult though!
Assuming that we only need to store the package name and function, yes the plan would be to store that in the yaml metadata. Hence it might break when you read the data on a machine that doesn't have the required package.