Skip to content

Commit 73b3d00

Browse files
committed
Complete example
1 parent 9545404 commit 73b3d00

22 files changed

+293
-46
lines changed

.Rbuildignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
^RcppTskitTestPkgLinkingTo\.Rproj$
1+
^RcppTskitTestLinking\.Rproj$
22
^\.Rproj\.user$
3+
^\.github$
34
^LICENSE\.md$

.github/workflows/R-CMD-check.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, devel]
6+
pull_request:
7+
8+
name: R-CMD-check.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
R-CMD-check:
14+
runs-on: ${{ matrix.config.os }}
15+
16+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
config:
22+
- { os: macos-latest, r: "release" }
23+
- { os: windows-latest, r: "release" }
24+
- { os: ubuntu-latest, r: "release" }
25+
26+
env:
27+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
28+
R_KEEP_PKG_SOURCE: yes
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: r-lib/actions/setup-pandoc@v2
34+
35+
- uses: r-lib/actions/setup-r@v2
36+
with:
37+
r-version: ${{ matrix.config.r }}
38+
http-user-agent: ${{ matrix.config.http-user-agent }}
39+
use-public-rspm: true
40+
41+
- uses: r-lib/actions/setup-r-dependencies@v2
42+
with:
43+
extra-packages: any::rcmdcheck
44+
needs: check
45+
46+
- uses: r-lib/actions/check-r-package@v2
47+
with:
48+
upload-snapshots: true
49+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55
.httr-oauth
66
.DS_Store
77
.quarto
8+
src/Makevars
9+
src/Makevars.in
10+
.gitignore
11+
src/RcppTskitTestLinking.so
12+
src/test.o
13+
.gitignore
14+
src/Makevars.in
15+
src/RcppExports.o

DESCRIPTION

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
Package: RcppTskitTestPkgLinkingTo
1+
Package: RcppTskitTestLinking
22
Title: Testing linking to and importing from RcppTskit
33
Version: 0.1.0
44
Authors@R:
55
person("Gregor", "Gorjanc", , "gregor.gorjanc@gmail.com", role = c("aut", "cre", "cph"))
6-
Description: This is a stub package that shows how to link to and import
6+
Description: This is a demo package that shows how to link to and import
77
from RcppTskit package, which provides R access to tskit C API.
88
License: MIT + file LICENSE
9+
Depends:
10+
R (>= 4.0.0)
11+
Imports:
12+
methods,
13+
RcppTskit (>= 0.1.0)
914
LinkingTo:
10-
RcppTskit
15+
Rcpp (>= 0.12.10),
16+
RcppTskit (>= 0.1.0)
1117
Remotes:
1218
git::git@bitbucket.org:HighlanderLab/RcppTskit.git?subdir=RcppTskit
1319
Encoding: UTF-8

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
YEAR: 2026
2-
COPYRIGHT HOLDER: RcppTskitTestPkgLinkingTo authors
2+
COPYRIGHT HOLDER: Gregor Gorjanc

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(ts_num_individuals_ptr2)
4+
import(RcppTskit)
5+
importFrom(methods,is)
6+
useDynLib(RcppTskitTestLinking, .registration = TRUE)

R/RcppExports.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
2+
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3+
4+
#' @title Get number of individuals in tree sequence
5+
#' @param ts an external pointer to a \code{tsk_treeseq_t} object.
6+
#' @return integer number of individuals.
7+
#' @examples
8+
#' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
9+
#' ts <- RcppTskit::ts_load(ts_file)
10+
#' ts$num_individuals()
11+
#' ts_num_individuals_ptr2(ts$pointer)
12+
#' @export
13+
ts_num_individuals_ptr2 <- function(ts) {
14+
.Call(`_RcppTskitTestLinking_ts_num_individuals_ptr2`, ts)
15+
}
16+

R/RcppTskitTestLinkingTo-package.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#' @description
2+
#' This is a demo package that shows how to link to and import from RcppTskit
3+
#' package, which provides R access to tskit C API.
4+
#' @keywords internal
5+
#'
6+
#' @useDynLib RcppTskitTestLinking, .registration = TRUE
7+
#' @importFrom methods is
8+
#' @import RcppTskit
9+
"_PACKAGE"

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11

2-
# RcppTskitTestPkgLinkingTo
2+
# RcppTskitTestLinking
33

4-
The goal of RcppTskitTestPkgLinkingTo is to demonstrate
5-
how to link to and import from RcppTskit package,
6-
which provides R access to tskit C API.
4+
This is a demo package that shows how to link to and import from RcppTskit
5+
package, which provides R access to tskit C API.
76

8-
## Installation
7+
## Key files
98

10-
You can install the development version of RcppTskitTestPkgLinkingTo like so:
9+
The key files you should study are:
1110

12-
``` r
13-
TODO
14-
```
11+
- `DESCRIPTION`
1512

16-
## Example
13+
- `R/RcppTskitTestLinking-package.R`
1714

18-
``` r
19-
library(RcppTskitTestPkgLinkingTo)
20-
TODO
21-
```
15+
- `src/test.cpp`
16+
17+
- `src/Makevars.in` and `src/Makevars.win.in`
18+
19+
- `tools/configure.R`
20+
21+
- `configure` and `configure.win`
2222

23+
- `cleanup` and `cleanup.win`
24+
25+
## Install and test
26+
27+
You can install and test this package by running:
28+
29+
```
30+
remotes::install_github("HighlanderLab/RcppTskitTestLinking")
31+
library(RcppTskitTestLinking)
32+
?ts_num_individuals2
33+
```

0 commit comments

Comments
 (0)