Happy to share that a new package RcppInt64 arrived on CRAN earlier today after a brief one-day inspection round. RcppInt64 collects some of the previous conversions between 64-bit integer values in R and C++, and regroups them in a single package.
A single header is provided. It actually offers two interfaces: both
a more standard as<>()
converter from R values along
with its companions wrap()
to return to R, as well as more
dedicated functions ‘from’ and ‘to’. A key difficulty faced when
supporting 64 bit integer payloads is that R has no proper type
for it so the standard template-based approaches use by Rcpp do not
apply. To ‘carry’ 64 bit integers, the clever approach by Jens
Oehlschlägel and his bit64 package is
used. However, its use of a double
to transport the
int64
payload means we must take care to not uninentionally
interpret the double
variables as, well,
double
. So we use an simple S3 class in R, and check for
it. With some care (as provided by these helper functions) this works
well.
The RcppInt64 packages contains both an example function, as well as an entire example package to demonstrate how to use these facilities in your package. We hope others will find this useful.
If you like this or other open-source work I do, you can sponsor me at GitHub.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.