Skip to content

Instantly share code, notes, and snippets.

@egouldo
Created March 8, 2021 08:21
Show Gist options
  • Save egouldo/605a1147e31d95846c08c331046301f1 to your computer and use it in GitHub Desktop.
Save egouldo/605a1147e31d95846c08c331046301f1 to your computer and use it in GitHub Desktop.
Rmarkdown reprex illustrating unexpected pointblank rendering behaviour
---
title: "Reprex: rendering fails or incomplete for list of pointblank tables in rmarkdown documents"
author: "Elliot Gould"
date: "08/03/2021"
output:
html_document:
keep_md: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(pointblank)
```
```{r, message=FALSE}
data("small_table")
df <- tibble(id = c(1,2), data = list(small_table))
validate_small_table <- function(data){
al <- action_levels(warn_at = 0.1, stop_at = 0.2)
agent <-
create_agent(
tbl = small_table,
tbl_name = "small_table",
label = "VALID-I Example No. 2",
actions = al
) %>%
col_is_posix(vars(date_time),label = "check that date_time col is posix") %>%
col_vals_in_set(vars(f), set = c("low", "mid")) %>%
col_vals_lt(vars(a), value = 7) %>%
col_vals_regex(vars(b), regex = "^[0-9]-[a-w]{3}-[2-9]{3}$") %>%
col_vals_between(vars(d), left = 0, right = 4000) %>%
interrogate()
return(agent)
}
validate_small_table(small_table)
df <- tibble(id = c(1,2), data = list(small_table)) %>%
mutate(result = map(.x = data, .f = ~ validate_small_table(.x)))
df$result # will not render without setting 'results = 'asis'' in chunk opts
df$result[[1]] # renders without setting 'results = 'asis'' in chunk opts
df$result %>% map(get_agent_report) # does not render without specifying results opt
```
In the next chunk below, I've set the chunk opt for `results` to `asis`:
```{r results='asis'}
df$result %>% map(get_agent_report) # renders, but not completely
```
<sup>Created on `r Sys.Date()` by the [reprex package](https://reprex.tidyverse.org) (v`r utils::packageVersion("reprex")`)</sup>
<details style="margin-bottom:10px;"> <summary>Session info</summary>
```{r }
sessioninfo::session_info()
```
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment