@@ -56,6 +56,10 @@ As the name suggests, `RcppTskit` leverages the `R` package `Rcpp`
5656which significantly lowers the barrier to using ` C++ ` with ` R ` .
5757However, we still need to write ` C++ ` wrappers and expose them to ` R ` ,
5858so we recommend using ` reticulate ` first.
59+ To understand which functions are implemented,
60+ users should explore the ` RcppTskit ` help pages of ` R ` functions,
61+ while developers should explore the underlying
62+ ` RcppTskit:::rtsk_* ` low-level ` R ` and ` C++ ` functions.
5963
6064## State of the tree sequence ecosystem
6165
@@ -201,18 +205,15 @@ so all editing should happen in `C/C++` or `Python`.
201205
202206## API mirroring across the languages
203207
204- The provided ` RcppTskit R ` API mirrors the ` tskit Python ` API,
205- while .
206-
207208` RcppTskit ` aims to keep naming, arguments, defaults, and behaviour aligned
208209with upstream ` tskit ` APIs whenever practical.
209210Specifically,
210- the provided ` RcppTskit R ` API mirrors the ` tskit Python ` API,
211- that is the functions and ` R6 ` classes (with their methods) aim to mirror
211+ the ` RcppTskit R ` API mirrors the ` tskit Python ` API;
212+ the ` R ` functions and ` R6 ` classes (with their methods) aim to mirror
212213` tskit Python ` functions and classes (with their methods).
213214Note that the ` RcppTskit R ` API is far more limited than the ` tskit Python ` API.
214215The ` RcppTskit C++ ` API aims to mirror the ` tskit C ` API functions and semantics,
215- but is deliberately ` R ` oriented
216+ but is deliberately ` R ` oriented.
216217When we intentionally deviate (for example, to support ` R ` idioms or safety),
217218we document the rationale and test the chosen behaviour.
218219
@@ -223,7 +224,8 @@ First install `RcppTskit` from CRAN and load it.
223224``` {r}
224225#| label: pre-setup
225226#| include: false
226- # Had issues on Windows (R reported that RcppTskit is not installed, which is odd).
227+ # Had issues on GitHub Windows
228+ # (R reported that RcppTskit is not installed, which is odd).
227229# This tries to "restore" the library path.
228230lib_env <- Sys.getenv("R_LIBS")
229231if (nzchar(lib_env)) {
@@ -264,10 +266,30 @@ tc$print()
264266# Convert the table collection to tree sequence
265267ts2 <- tc$tree_sequence()
266268
267- # Explore the help pages
269+ # Users should explore the help pages
268270help(package = "RcppTskit")
269271```
270272
273+ Developers should also explore the low-level ` R ` and ` C++ ` functions.
274+ Their names all start with ` rtsk_ ` and are accessible via ` RcppTskit::: ` .
275+ For example, the above ` R ` function ` ts_load() ` effectively calls:
276+
277+ ``` {r}
278+ #| label: use_case_1_dev_funcs
279+ # Low-level R function, which further calls the C++ function
280+ RcppTskit:::rtsk_treeseq_load
281+
282+ # C++ function (see also the C++ source code)
283+ RcppTskit:::`_RcppTskit_rtsk_treeseq_load`
284+
285+ # The same as the ts_load() example, but exposing the external pointer
286+ xptr <- RcppTskit:::rtsk_treeseq_load(ts_file)
287+ methods::is(xptr)
288+
289+ # We pass the external pointer to other low-level functions
290+ RcppTskit:::rtsk_treeseq_get_num_individuals(xptr)
291+ ```
292+
271293### 2) Pass a tree sequence between ` R ` and reticulate or standard ` Python `
272294
273295``` {r}
0 commit comments