Conversation
| dt = data.table::as.data.table(iris) | ||
| Rcpp::cppFunction("SEXP mysub2(SEXP x, SEXP rows, SEXP cols) { return DT_subsetDT(x,rows,cols); }", | ||
| include="#include <datatableAPI.h>", | ||
| depends="data.table") | ||
| mysub2(dt, 1:4, 1:4) |
There was a problem hiding this comment.
This Dirk example is really nice and shows how new header can be nicely used. I would like to provide pure C example as well but cannot get it to work.
dt = data.table::as.data.table(iris)
mysub1 = inline::cfunction(sig=c(x="SEXP", rows="integer", cols="integer"),
"return DT_subsetDT(x,rows,cols); ",
includes = "#include <datatableAPI.h>",
cppargs = paste0("-I",system.file("include", package="data.table")),
language = "C")@eddelbuettel any idea how to effectively use new header file for linking from C? if possible just base R, not even inline, for simplicity
There was a problem hiding this comment.
@jangorecki Can you please rephrase that question? What is your are asking? Header files are using during compilation only (and we can all blame R's LinkingTo: for confusion). Are you aiming for an example in R using a header file but no compiler? I can't quite square it ...
There was a problem hiding this comment.
Strictly speaking an example of importing DT's functions by importing API header rather than R_GetCCallable("data.table", "DT_subsetDT"). For use from C rather than C++.
There was a problem hiding this comment.
Are you asking if I have a package hanging around that uses the new C header? No, as it is still fairly new.
But you could take aim at for example RcppXts which was set up (well over seven and a half years ago !!) to do the same xts and the export header there.
It would be possible (and in fact very valuable) to have a similar examples package for data.table. But right now we have ... one function. Little stretched for an example package.
Codecov Report
@@ Coverage Diff @@
## master #4753 +/- ##
=======================================
Coverage 99.42% 99.42%
=======================================
Files 73 73
Lines 14430 14430
=======================================
Hits 14347 14347
Misses 83 83
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Looks good to me (modulo the one inline comment). I'd have to run a test compilation to see "for sure" if all locations of the old identifier have been renamed but I trust @jangorecki on this.
Improved docs for recently provided header file for exported functions.
Note that there is a rename of exported C function.