簡體   English   中英

是否可以為 RMarkdown 禁用`callr`?

[英]Is it possible to disable `callr` for RMarkdown?

嘗試為 {disk.frame} 構建小插圖時,我不斷收到錯誤消息。 我認為這是由於 {callr} 與 NSE 的錯誤行為。

是否可以不將 {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)
```

基於此處的討論https://community.rstudio.com/t/error-with-callr-not-doing-nse-the-way-disk-frame-does-causing-issue-with-knitting-in-rmarkdown /47401

可以簡單地直接在文件上使用rmarkdown::render()來規避這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM