Skip to content

Commit 495fec1

Browse files
committed
Vignette fixes to build
1 parent 66ed70e commit 495fec1

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Suggests:
9494
knitr,
9595
rmarkdown,
9696
sf,
97+
spatstat.data,
9798
splancs,
9899
testthat,
99100
tibble,

vignettes/articles/forecasting.Rmd

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ knitr::opts_chunk$set(
2929
library(sdmTMB)
3030
library(dplyr)
3131
library(ggplot2)
32-
library(spatstat.data)
3332
```
3433

3534
Here we will cover using sdmTMB for forecasting data in time or extrapolating spatially to unsampled areas.
@@ -151,7 +150,7 @@ We can also add a smoother on year as a variable in the model equation with `s(y
151150

152151
```{r, fit-sm, results='hide', message=FALSE, warning=FALSE}
153152
fit_sm <- sdmTMB(
154-
density ~ s(year) + depth_scaled + depth_scaled2, #<< add smoother on year
153+
density ~ s(year, k = 5) + depth_scaled + depth_scaled2, #<< add smoother on year
155154
time = "year",
156155
extra_time = extra_years, #<<
157156
spatiotemporal = "AR1", #<<
@@ -221,11 +220,7 @@ ggplot(pred_df, aes(year, exp(est), ymin = exp(est - 2 * est_se), ymax = exp(est
221220
We can see how AR(1) spatiotemporal fields evolve towards mean zero by mapping the magnitude of the spatio-temporal term epsilon over the entire period 2003--2025
222221

223222
```{r pred-ar1-plot-eps, echo=FALSE}
224-
one_yr <- dplyr::filter(qcs_grid, year == 2017)
225-
grid <- purrr::map_dfr(unique(fit_ar1$data$year), function(i) { # FIXME remove purrr or add to suggests!
226-
one_yr$year <- i
227-
one_yr
228-
})
223+
grid <- replicate_df(qcs_grid, "year", time_values = unique(fit_ar1$data$year))
229224
p_ar1 <- predict(fit_ar1, newdata = grid)
230225
ggplot(p_ar1, aes(X, Y, fill = epsilon_st)) +
231226
geom_raster() +
@@ -406,7 +401,7 @@ Here, we expand the geographic domain by 100 in all directions, and keep the res
406401

407402
Then, we can use the same model fit to predict to the expanded geographic domain.
408403

409-
```{r pred-fit2, echo=FALSE, eval=TRUE}
404+
```{r pred-fit2, echo=FALSE, eval=TRUE, message=FALSE, warning=FALSE}
410405
# makes all combinations of x and y:
411406
newdf <- expand.grid(
412407
x = seq(min(dat$x) - 100, max(dat$x) + 100, 5),

vignettes/articles/presence-only.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ vignette: >
1212
```{r setup, include = FALSE, cache=FALSE}
1313
dplyr_installed <- require("dplyr", quietly = TRUE)
1414
ggplot_installed <- require("ggplot2", quietly = TRUE)
15-
patstat.data_installed <- require("spatstat.data", quietly = TRUE)
15+
spatstat.data_installed <- require("spatstat.data", quietly = TRUE)
1616
pkgs <- dplyr_installed && ggplot_installed && spatstat.data_installed
1717
knitr::opts_chunk$set(
1818
collapse = TRUE,
1919
comment = "#>",
2020
fig.width = 7,
2121
fig.asp = 0.618,
22-
eval = EVAL,
23-
purl = EVAL
22+
eval = identical(Sys.getenv("NOT_CRAN"), "true") && pkgs,
23+
purl = identical(Sys.getenv("NOT_CRAN"), "true") && pkgs
2424
)
2525
```
2626

0 commit comments

Comments
 (0)