Skip to content

Commit

Permalink
Add RcppArmadillo dependency to get around R CMD Check NOTE
Browse files Browse the repository at this point in the history
  • Loading branch information
graemeleehickey committed Feb 3, 2025
1 parent dba10d0 commit 06ddf4c
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 53 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Imports:
parallel,
randtoolbox,
Rcpp (>= 0.12.7),
RcppArmadillo,
stats,
tibble,
utils
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ importFrom(MASS,ginv)
importFrom(MASS,mvrnorm)
importFrom(Matrix,nearPD)
importFrom(Rcpp,evalCpp)
importFrom(RcppArmadillo,armadillo_reset_cores)
importFrom(RcppArmadillo,armadillo_throttle_cores)
importFrom(cobs,cobs)
importFrom(doParallel,registerDoParallel)
importFrom(generics,augment)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

- Add R-hub workflow to enable checks for platforms not covered already.

- Imported `RcppArmadillo` functions `armadillo_throttle_cores` and `armadillo_reset_cores` to try and prevent CRAN R CMD checks using multiple threads.

- Updated Makevars (now Makevars.in) and Makevars.win as part of previous update.

# joineRML 0.4.6

## Housekeeping
Expand Down
1 change: 1 addition & 0 deletions R/joineRML.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#'
#' @useDynLib joineRML, .registration = TRUE
#' @importFrom Rcpp evalCpp
#' @importFrom RcppArmadillo armadillo_throttle_cores armadillo_reset_cores
#'
#' @references
#' Wulfsohn MS, Tsiatis AA. A joint model for survival and longitudinal data
Expand Down
2 changes: 0 additions & 2 deletions src/Makevars

This file was deleted.

3 changes: 3 additions & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PKG_CPPFLAGS = -I../inst/include
PKG_CXXFLAGS = @OPENMP_FLAG@
PKG_LIBS= @OPENMP_FLAG@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
2 changes: 1 addition & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS = -I../inst/include -I. $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
16 changes: 16 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,19 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_joineRML_expWArma", (DL_FUNC) &_joineRML_expWArma, 4},
{"_joineRML_gammaUpdate", (DL_FUNC) &_joineRML_gammaUpdate, 11},
{"_joineRML_hazHat", (DL_FUNC) &_joineRML_hazHat, 3},
{"_joineRML_gammaUpdate_approx", (DL_FUNC) &_joineRML_gammaUpdate_approx, 10},
{"_joineRML_lambdaUpdate", (DL_FUNC) &_joineRML_lambdaUpdate, 10},
{"_joineRML_mvrnormArma", (DL_FUNC) &_joineRML_mvrnormArma, 3},
{"_joineRML_bSim", (DL_FUNC) &_joineRML_bSim, 3},
{NULL, NULL, 0}
};

RcppExport void R_init_joineRML(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
34 changes: 0 additions & 34 deletions src/init.c

This file was deleted.

22 changes: 15 additions & 7 deletions vignettes/joineRML-tidy.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ vignette: >
---

```{r load-joineRML, include=FALSE}
library(RcppArmadillo)
RcppArmadillo::armadillo_throttle_cores(2)
Sys.setenv(OMP_THREAD_LIMIT = 1)
Sys.setenv(OMP_NUM_THREADS = 1)
Sys.setenv(OPENBLAS_NUM_THREADS = 1)
Sys.setenv(ARMA_OPENMP_THREADS = 1)
Sys.setenv(R_INSTALL_NCPUS = 1)
options(Ncpus = 1)
library(joineRML)
library(knitr)
Sys.setenv("OMP_THREAD_LIMIT" = 1)
Sys.setenv("OMP_NUM_THREADS" = 1)
Sys.setenv("OPENBLAS_NUM_THREADS" = 1)
Sys.setenv("ARMA_OPENMP_THREADS" = 1)
options(Ncpus = 1)
```

# Introduction
Expand Down Expand Up @@ -60,7 +64,7 @@ Further to that, we only select the first 50 individuals to speed up these examp
hvd <- hvd[hvd$num <= 50, ]
```

```{r hvd_model_fit, cache=TRUE}
```{r hvd_model_fit}
set.seed(12345)
fit <- mjoint(
formLongFixed = list(
Expand Down Expand Up @@ -185,3 +189,7 @@ Several examples of how to use `broom` including more details are available on i
```{r vignette-broom, eval=FALSE, purl=FALSE}
vignette(topic = "broom", package = "broom")
```

```{r, echo=FALSE, message=FALSE}
RcppArmadillo::armadillo_reset_cores()
```
26 changes: 17 additions & 9 deletions vignettes/joineRML.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ vignette: >
---

```{r, echo=FALSE, message=FALSE}
library(RcppArmadillo)
RcppArmadillo::armadillo_throttle_cores(n = 2)
Sys.setenv(OMP_THREAD_LIMIT = 1)
Sys.setenv(OMP_NUM_THREADS = 1)
Sys.setenv(OPENBLAS_NUM_THREADS = 1)
Sys.setenv(ARMA_OPENMP_THREADS = 1)
Sys.setenv(R_INSTALL_NCPUS = 1)
options(Ncpus = 1)
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(Matrix)
library(nlme)
Expand All @@ -21,12 +31,6 @@ if (requireNamespace('joineR', quietly = TRUE)) {
} else {
message("'joineR' not available")
}
Sys.setenv("OMP_THREAD_LIMIT" = 1)
Sys.setenv("OMP_NUM_THREADS" = 1)
Sys.setenv("OPENBLAS_NUM_THREADS" = 1)
Sys.setenv("ARMA_OPENMP_THREADS" = 1)
options(Ncpus = 1)
```

# Introduction
Expand Down Expand Up @@ -92,7 +96,7 @@ The main function in the `joineRML` package is the `mjoint()` function. Its main

We can fit a bivariate joint model to the log-transformed valve gradient and LVMI indices in the `hvd` subset using

```{r hvd_model_fit, cache=TRUE}
```{r hvd_model_fit}
set.seed(12345)
fit <- mjoint(
formLongFixed = list("grad" = log.grad ~ time + sex + hs,
Expand Down Expand Up @@ -175,7 +179,7 @@ To fit a univariate model in `joineR` we run the following code for the `hvd` da
joineR_available <- require(joineR)
```

```{r joineR, cache=TRUE, eval=joineR_available, purl=joineR_available}
```{r joineR, eval=joineR_available, purl=joineR_available}
library(joineR, quietly = TRUE)
hvd.surv <- UniqueVariables(hvd, var.col = c("fuyrs", "status"), id.col = "num")
Expand All @@ -198,7 +202,7 @@ summary(fit.joiner)

To fit a univariate model in `joineRML` we run the following code for the `hvd` data

```{r joineRML, cache=TRUE}
```{r joineRML}
set.seed(123)
fit.joinerml <- mjoint(formLongFixed = log.lvmi ~ time + age,
formLongRandom = ~ time | num,
Expand Down Expand Up @@ -226,3 +230,7 @@ plot(fit.joiner$coefficients$random[id.ord, 2], ranef(fit.joinerml)[, 2],
grid()
abline(a = 0, b = 1, col = 2, lty = "dashed")
```

```{r, echo=FALSE, message=FALSE}
RcppArmadillo::armadillo_reset_cores()
```

0 comments on commit 06ddf4c

Please sign in to comment.