@@ -293,7 +293,8 @@ To call the `tskit` C API in your own R package via `Rcpp`
293293you can leverage ` RcppTskit ` , which will simplify your installation
294294and enable you to quickly call
295295To do this, follow the steps below and check how these were implemented in
296- the test R package ` RcppTskitTestLinkingTo ` at https://github.com/HighlanderLab/RcppTskitTestLinking .
296+ the demo R package ` RcppTskitTestLinkingTo ` at
297+ https://github.com/HighlanderLab/RcppTskitTestLinking .
297298
298299a) Open ` DESCRIPTION ` file and
299300 add ` RcppTskit ` to the ` Imports: ` and ` LinkingTo: ` field, and further
@@ -332,31 +333,27 @@ h) You should now be ready to build, check, and install your package using
332333 ` devtools::build() ` , ` devtools::check() ` , and ` devtools::install() `
333334 or their ` R CMD ` equivalents.
334335
336+ Here is code you can run to check out ` RcppTskitTestLinkingTo ` :
337+
335338``` {r}
336339#| label: use_case_4
337340#| eval: false
338- #| echo: false
341+ # Install and load the demo package
342+ remotes::install_github("HighlanderLab/RcppTskitTestLinking")
343+ library(RcppTskitTestLinking)
339344
340- # This code will not work atm because we used tskitr!
341- # TODO: Create a minimal package to demonstrate how to link against RcppTskit and call tskit C API
345+ # Check the demo function
346+ print(ts_num_individuals_ptr2)
342347
343- # Install AlphaSimR
344- # (Commit with a proof of concept of using tskit C API;
345- # study the file contents in there! Can also use later commits.)
346- remotes::install_github(
347- repo = "HighlanderLab/AlphaSimR",
348- ref = "12657b08e7054d88bc214413d13f36c7cde60d95"
349- )
348+ # Example tree sequence
349+ ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
350+ ts <- ts_load(ts_file)
350351
351- # Load packages
352- library(RcppTskit)
353- library(AlphaSimR)
352+ # Function from RcppTskit (working with TreeSequence R6 class)
353+ ts$num_individuals()
354354
355- # Load tree sequence and count the number of individuals
356- ts_file <- system.file("examples/test.trees", package = "RcppTskit")
357- ts <- ts_load(ts_file)
358- RcppTskit::ts_num_individuals(ts)
359- AlphaSimR::ts_num_individuals2(ts)
355+ # Function from RcppTskitTestLinking (working with externalptr)
356+ ts_num_individuals_ptr2(ts$pointer)
360357```
361358
362359## Conclusion
0 commit comments