Commit a0d24c8b by Eric Coissac

make doParallel optionnal and should solve the windows problem during CRAN checks

parent c4c6c590
......@@ -16,7 +16,6 @@ Imports: MASS,
Matrix,
mvtnorm,
stats,
doParallel,
foreach,
Rdpack
Suggests: knitr,
......@@ -24,7 +23,8 @@ Suggests: knitr,
roxygen2,
vegan,
testthat,
ade4
ade4,
doParallel
RdMacros: Rdpack
Collate:
'internals.R'
......
......@@ -38,7 +38,6 @@ export(simulate_correlation)
export(simulate_matrix)
export(varls)
import(MASS)
import(doParallel)
import(foreach)
import(permute)
import(stats)
......
#' @include procmod.R
#' @include procmod_frame.R
#' @include multivariate.R
#' @import doParallel
#' @import foreach
#' @import stats
#'
......@@ -9,8 +8,8 @@
#' @author Eric Coissac
NULL
library(doParallel)
registerDoParallel(1)
.has_doParallel <- is.element("doParallel",installed.packages())
if (.has_doParallel) require(doParallel)
#' Compute the trace of a square matrix.
#'
......@@ -193,10 +192,15 @@ varls <- function(...,
for (i in seq_len(nx))
v_xs[[i]] <- var(xs[[i]])
if (! getDoParRegistered()) registerDoParallel(1)
if (.has_doParallel && getDoParRegistered()) {
`%dp%` <- `%dopar%`
}
else{
`%dp%` <- `%do%`
}
s_cov_xxs <- foreach(k = seq_len(nrand),
.combine = cbind) %dopar% {
.combine = cbind) %dp% {
s1_cov_xxs <- matrix(0, nrow = nx, ncol = nx)
r_xs <- vector(mode = "list", nx)
r_ys <- vector(mode = "list", nx)
......
......@@ -61,10 +61,10 @@ simulate_matrix <- function(n, p, equal_var = TRUE) {
#' @return a numeric matrix of \code{nrow(reference)} rows and \code{p} columns
#'
#' @examples
#' sim1 <- simulate_matrix(15,5)
#' sim1 <- simulate_matrix(25,10)
#' class(sim1)
#' dim(sim1)
#' sim2 <- simulate_correlation(sim1,10,0.8)
#' sim2 <- simulate_correlation(sim1,20,0.8)
#' corls(sim1, sim2)^2
#'
#' @author Eric Coissac
......
......@@ -35,10 +35,10 @@ The intensity of the correlation is determined by the \code{r2}
parameter.
}
\examples{
sim1 <- simulate_matrix(15,5)
sim1 <- simulate_matrix(25,10)
class(sim1)
dim(sim1)
sim2 <- simulate_correlation(sim1,10,0.8)
sim2 <- simulate_correlation(sim1,20,0.8)
corls(sim1, sim2)^2
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment