尝试为 {disk.frame} 构建小插图时,我不断收到错误消息。我认为这是由于使用 NSE 的 {callr} 的错误行为。
是否可以不将 {callr} 与 RMarkdown 一起使用?我认为 {callr} 在后台创建了一个新的 R 会话,但如果我只是使用同一个会话来构建 Markdown,那么我应该没问题。但是我在 Rmarkdown 文档中找不到可以禁用 {callr} 的位置。
--- re-building 'intro-disk-frame.Rmd' using rmarkdown
Quitting from lines 230-235 (intro-disk-frame.Rmd)
Error: processing vignette 'intro-disk-frame.Rmd' failed with diagnostics:
no applicable method for 'filter_' applied to an object of class "NULL"
--- failed re-building 'intro-disk-frame.Rmd'
SUMMARY: processing the following file failed:
'intro-disk-frame.Rmd'
Error : Vignette re-building failed.
Error: <callr_status_error: callr subprocess failed: Vignette re-building failed.>
-->
<callr_remote_error: Vignette re-building failed.>
in process 17276
See `.Last.error.trace` for a stack trace.
Warning message:
In df_setup_vignette(excl = c("08-more-epic.Rmd", "06-vs-dask-juliadb.Rmd", :
NAs introduced by coercion
更新
这是您可以尝试的代码
---
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)
```