Skip to content

Commit

Permalink
Add conditional use of INLA to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRegular committed Sep 18, 2023
1 parent 0378248 commit 28daf1f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
4 changes: 2 additions & 2 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.1.6
Date: 2023-09-15 16:02:07 UTC
SHA: 8a489a48ddcde0fd7b4554e983c3c3b9ffd77acf
Date: 2023-09-15 18:15:02 UTC
SHA: 03782485a4ec155145da49da0476c498a1b019e2
41 changes: 26 additions & 15 deletions R/sim_dist_spde.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,25 @@
#'
#' \donttest{
#'
#' ## Make a grid
#' my_grid <- make_grid(res = c(10,10))
#' if (requireNamespace("INLA")) {
#'
#' ## Make a mesh based off it
#' ## Make a grid
#' my_grid <- make_grid(res = c(10,10))
#'
#' my_mesh <- make_mesh(my_grid)
#' sim <- sim_abundance(ages = 1:10, years = 1:10) %>%
#' sim_distribution(grid = my_grid,
#' ays_covar = sim_ays_covar_spde(phi_age = 0.8,
#' phi_year = 0.1,
#' model = "spde",
#' mesh = my_mesh),
#' depth_par = sim_parabola(mu = 200,
#' sigma = 50))
#' plot_distribution(sim, ages = 1:5, years = 1:5, type = "heatmap")
#' ## Make a mesh based off it
#'
#' my_mesh <- make_mesh(my_grid)
#' sim <- sim_abundance(ages = 1:10, years = 1:10) %>%
#' sim_distribution(grid = my_grid,
#' ays_covar = sim_ays_covar_spde(phi_age = 0.8,
#' phi_year = 0.1,
#' model = "spde",
#' mesh = my_mesh),
#' depth_par = sim_parabola(mu = 200,
#' sigma = 50))
#' plot_distribution(sim, ages = 1:5, years = 1:5, type = "heatmap")
#'
#' }
#'
#' }
#'
Expand All @@ -107,6 +110,12 @@ sim_ays_covar_spde <- function(sd = 2.8,

function(x = NULL, ages = NULL, years = NULL, cells = NULL){

for (pkg in c("INLA")) {
if (!requireNamespace(pkg, quietly = TRUE)) {
stop(paste(pkg, "is needed for make_mesh to work. Please install it."), call. = FALSE)
}
}

na <- length(ages)
ny <- length(years)
nc <- length(cells)
Expand Down Expand Up @@ -222,8 +231,10 @@ sim_ays_covar_spde <- function(sd = 2.8,
#'
#' \donttest{
#'
#' basic_mesh <- make_mesh()
#' plot(basic_mesh)
#' if (requireNamespace("INLA")) {
#' basic_mesh <- make_mesh()
#' plot(basic_mesh)
#' }
#'
#' }
#'
Expand Down
6 changes: 4 additions & 2 deletions man/make_mesh.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 18 additions & 15 deletions man/sim_ays_covar_spde.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28daf1f

Please sign in to comment.