gpt4 book ai didi

r - Bookdown - 在哪里加载包

转载 作者:行者123 更新时间:2023-12-02 02:54:25 25 4
gpt4 key购买 nike

我有一个大型书籍项目,我想检查一个章节是否有效。
我已经编写了它,以便我需要的所有包都加载到 Index.Rmd

但是,当我尝试渲染这本书或预览一章时,它作为功能失败 %>%未找到,即使 library(dplyr)在 Index.Rmd 中。

真的有必要在 bookdown 项目的每一章开头加载相同的包吗?还是我错过了什么?

最佳答案

Is it really necessary to load the same packages 
at the start of each chapter in a bookdown project?
这取决于您的 knitr 方法:

Merging all chapters into one Rmd file and knitting it is one way to render the book in bookdown. There is actually another way: you may knit each chapter in a separate R session, and bookdown will merge the Markdown output of all chapters to render the book. We call these two approaches “Merge and Knit” (M-K) and “Knit and Merge” (K-M), respectively. …

M-K runs all code chunks in all chapters in the same R session, whereas K-M uses separate R sessions for individual chapters. For M-K, the state of the R session from previous chapters is carried over to later chapters (e.g., objects created in previous chapters are available to later chapters, unless you deliberately deleted them); for K-M, all chapters are isolated from each other.


如果您不想加载库,也可以使用 :: 引用该函数。符号,例如 knitr::kable(head(iris, 20))补充:有关如何继续的更多信息,请查看 bookdown manual .

关于r - Bookdown - 在哪里加载包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50293383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com