From 8294c2b3a6f4411e7f2e74a70cacda7c945af187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sun, 5 Nov 2023 07:01:52 +0100 Subject: [PATCH] docs: Fix rendering if suggested packages are missing --- vignettes/formats.Rmd | 3 +++ vignettes/numbers.Rmd | 2 +- vignettes/types.Rmd | 10 +++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/vignettes/formats.Rmd b/vignettes/formats.Rmd index 470ce8c8a..6649ee3b9 100644 --- a/vignettes/formats.Rmd +++ b/vignettes/formats.Rmd @@ -12,9 +12,12 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", + eval = rlang::is_installed(c("dplyr", "formattable", "ggplot2", "tidyr")), error = (Sys.getenv("IN_PKGDOWN") == "") ) +``` +```{r, include = FALSE} library(tibble) library(formattable) library(dplyr) diff --git a/vignettes/numbers.Rmd b/vignettes/numbers.Rmd index 88c5387d1..e86bfb01c 100644 --- a/vignettes/numbers.Rmd +++ b/vignettes/numbers.Rmd @@ -70,7 +70,7 @@ The formatting survives most data transformations. Currently, formatting must be applied manually for each column. The following pattern may help doing this consistently for all columns in a tibble, or for some columns based on their name. -```{r} +```{r, eval = rlang::is_installed("dplyr")} library(dplyr, warn.conflicts = FALSE) markets <- diff --git a/vignettes/types.Rmd b/vignettes/types.Rmd index 07e13c393..c4977ad69 100644 --- a/vignettes/types.Rmd +++ b/vignettes/types.Rmd @@ -10,8 +10,12 @@ vignette: > ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, + eval = rlang::is_installed(c("dplyr", "tidyr", "purrr")), comment = "#>" ) +``` + +```{r, include = FALSE} library(dplyr) library(tidyr) library(purrr) @@ -48,7 +52,7 @@ set_names(rep_along(all_methods, list("")), all_methods) %>% ```{r data, echo = FALSE} -data <- list( +data <- compact(list( "Atomic" = rlang::quos( logical = TRUE, integer = 1L, @@ -68,7 +72,7 @@ data <- list( difftime = vctrs::new_duration(1) ), - "Objects from other packages" = rlang::quos( + "Objects from other packages" = if (rlang::is_installed(c("bit64", "blob", "hms"))) rlang::quos( hms = hms::hms(1), integer64 = bit64::as.integer64(1e10), blob = blob::blob(raw(1)) @@ -99,7 +103,7 @@ data <- list( expression = parse(text = "a <- 1\nb<- 2"), quosures = rlang::quos(a = 1) ) -) +)) ``` ```{r table, echo = FALSE}