Actually, I am not 100% sure what the issue might be. But I think it's to do with how {callr} does the NSE and in particular how it fails to capture vital global variables.
However, I don't get this error when I start a fresh session and just run this. I can't seem to figure out what the issue is except my initial hypothesis.
Below the code. Side question how do I format the code properly? Wrapping it in doesn't work as rmarkdown already contains some.
---
title: "Test"
output: rmarkdown::html_vignette
---
``` {r setup, include = FALSE}
remotes::install_github("xiaodaigh/disk.frame", ref="development")
suppressPackageStartupMessages(library(disk.frame))
library(fst)
library(magrittr)
library(nycflights13)
library(dplyr)
library(data.table)
# you need to run this for multi-worker support
# limit to 2 cores if not running interactively; most likely on CRAN
# set-up disk.frame to use multiple workers
if(interactive()) {
setup_disk.frame()
# highly recommended, however it is pun into interactive() for CRAN because
# change user options are not allowed on CRAN
options(future.globals.maxSize = Inf)
} else {
setup_disk.frame(2)
}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r asdiskframe, cache=TRUE}
library(nycflights13)
library(dplyr)
library(disk.frame)
library(data.table)
# convert the flights data to a disk.frame and store the disk.frame in the folder
# "tmp_flights" and overwrite any content if needed
flights.df <- as.disk.frame(
flights,
outdir = file.path(tempdir(), "tmp_flights.df"),
overwrite = TRUE)
flights.df
```
```{r, dependson='asdiskframe'}
library(disk.frame)
flights.df %>%
group_by(carrier) %>% # notice that hard_group_by needs to be set
summarize(count = n(), mean_dep_delay = mean(dep_delay, na.rm=T)) %>% # mean follows normal R rules
collect %>%
arrange(carrier)
```
where gpd may be NULL from the error message about filter_. It seems getParseData returns NULL here...
As it works interactively, it is not easy to debug this part, and see what gpd really is.
I tried this to debug
session <- callr::r_session$new()
session$run(function() rmarkdown::render("test.rmd", envir = globalenv()))
# error so enter debug mode
session$debug()
And in debug mode
# Go into generate_summ_code frame
.inspect 28
# See what gpd is
code = substitute(list(...))[-1]
getParseData(parse(text = deparse(code[[1]])), includeText = TRUE)
It returns NULL...
To close debug mode, ESC then
session$close()
The issue seems to be with getParseData returning NULL as not founding what it is looking for.