From 5b96362df5cfacac3a9c444179e39da80a122c3c Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 27 Oct 2023 09:43:04 +0200 Subject: [PATCH] fix vignette issues --- vignettes/simulate_residuals.Rmd | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/vignettes/simulate_residuals.Rmd b/vignettes/simulate_residuals.Rmd index 0c0872b21..7338aea4e 100644 --- a/vignettes/simulate_residuals.Rmd +++ b/vignettes/simulate_residuals.Rmd @@ -14,9 +14,29 @@ editor_options: chunk_output_type: console --- -```{r} -devtools::load_all() -library(DHARMa) +```{r , include=FALSE} +library(knitr) +library(performance) +options(knitr.kable.NA = "") +knitr::opts_chunk$set( + comment = ">", + message = FALSE, + warning = FALSE, + out.width = "100%", + dpi = 450 +) +options(digits = 2) + +pkgs <- c("DHARMa", "glmmTMB") +successfully_loaded <- vapply(pkgs, requireNamespace, FUN.VALUE = logical(1L), quietly = TRUE) +can_evaluate <- all(successfully_loaded) + +if (can_evaluate) { + knitr::opts_chunk$set(eval = TRUE) + vapply(pkgs, require, FUN.VALUE = logical(1L), quietly = TRUE, character.only = TRUE) +} else { + knitr::opts_chunk$set(eval = FALSE) +} ``` The basic workflow for simulated residual checks using `simulate_residuals()` is as follows. @@ -45,6 +65,7 @@ simulated_residuals Note that since this inherits the DHARMa class, all the methods implemented in DHARMa just work, including all the tests: ```{r} +library(DHARMa) residuals(simulated_residuals) DHARMa::testUniformity(simulated_residuals, plot = FALSE)