git2rdata icon indicating copy to clipboard operation
git2rdata copied to clipboard

Add integer64 support

Open AnthonyEbert opened this issue 10 months ago • 3 comments

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

AnthonyEbert avatar Mar 17 '25 13:03 AnthonyEbert

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

ThierryO avatar Mar 19 '25 11:03 ThierryO

That would be great!

Would it save this convert argument in the yaml metadata? That would be ideal, maybe difficult though!

AnthonyEbert avatar Mar 20 '25 12:03 AnthonyEbert

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.

ThierryO avatar Mar 20 '25 13:03 ThierryO