Dirk Eddelbuettel — written Jan 31, 2013 — source
Earlier today the new BH package arrived on CRAN. Over the years, Jay Emerson, Michael Kane and I had numerous discussions about a basic Boost infrastructure package providing Boost headers for other CRAN packages. JJ and Romain chipped in as well, and Jay finally took the lead by first creating a repo on R-Forge. And now the package is out, so what follows is a little demo.
This example borrows something already implemented in my RcppBDT package which wraps
code from Boost Date_Time for R.
Here, we compute the so-called IMM Date – generally the
the third Wednesday of the month (in the last month of the quarter). Boost has a function computing the Nth day of the Mth week
for a given month in a given year: we use that here with Wednesday and the third week.
The kicker is that Boost uses templates almost exclusively. So by declaring an depends attribute on BH, we ensure that the compilation will see the headers files provided by BH. Which happen to be the Boost headers, as that is what the package does. And that is all it takes.
We can test this from R for 2013 by computing the first two:
[1] "2013-03-20"
[1] "2013-06-19"
And for kicks, the same for 2033:
[1] "2033-03-16"
[1] "2033-06-15"
The BH package is still pretty raw. For example, yesterday’s Rcpp Gallery post on Boost foreach] does not build as we have not yet included the relevant Boost library. So far, BH reflects the needs of Jay and Mike in their (awesome) bigmemory project and my needs in RcppBDT, and then some. For the rest, let us know what may be missing.
Tweet