gpt4 book ai didi

r - 如何让 webshot 与 bookdown 一起使用?

转载 作者:行者123 更新时间:2023-12-03 20:50:52 25 4
gpt4 key购买 nike

我正在使用 bookdown以 PDF 和 HTML 格式创建“书”。
在我有 HTML 视频的地方,我在渲染时收到此消息:

Error: Functions that produce HTML output found in document targeting latex output.Please change the output type of this document to HTML. Alternatively, you can allowHTML output in non-HTML formats by adding this option to the YAML front-matter ofyour rmarkdown file:

always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats.


遵循有关 always_allow_html 的这些说明似乎被yihui ( https://github.com/rstudio/bookdown/issues/440 ) 劝阻了:

You should not add always_allow_html: yes to YAML.


因此,搜索会产生一个解决方案(例如 https://bookdown.org/yihui/bookdown/html-widgets.html ):

Since knitr v1.13, HTML widgets will be rendered automatically as screenshots taken via the webshot package (Chang 2019). Of course, you need to install the webshot package. Additionally, you have to install PhantomJS (http://phantomjs.org), since it is what webshot uses to capture screenshots. Both webshot and PhantomJS can be installed automatically from R:


......以及一些我遵循的指示。
所以现在,我有 webshotphantomjs按照这些说明下载并安装,这很容易确认:
> webshot::is_phantomjs_installed()
[1] TRUE
> webshot:install_phantomjs()
It seems that the version of `phantomjs` installed is greater than or equal to the requested version.To install the requested version or downgrade to another version, use `force = TRUE`.
Error in webshot:install_phantomjs() : argument of length 0
我是否使用 webshot:install_phantomjs()webshot:install_phantomjs(force=TRUE) , 没有什么改变。
确实,这失败了:
> webshot:install_phantomjs(version="2.1.1", force=TRUE)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 637 100 637 0 0 0 1585 0 --:--:-- --:--:-- --:---:-- --:--:-- 1588
0 16.3M 100 16.3M 100 16.3M 0 0 3244k 0 0:00:05 0:00:05 --:--:-- 3926k
0:01 0:10:39 49930phantomjs has been installed to /Users/pdunn2/Library/Application Support/PhantomJS
Error in webshot:install_phantomjs(version = "2.1.1", force = TRUE) :
argument of length 0
所以...如果 webshotphantomjs似乎已安装...我做错了什么?
谢谢指导...
P。
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] webshot_0.5.2 bookdown_0.20

loaded via a namespace (and not attached):
[1] packrat_0.5.0 digest_0.6.25 jsonlite_1.7.0 magrittr_1.5 evaluate_0.14 rlang_0.4.7 stringi_1.4.6
[8] curl_4.3 rstudioapi_0.11 rmarkdown_2.3 webshot_0.5.2 tools_4.0.2 stringr_1.4.0 xfun_0.15
[15] yaml_2.2.1 rsconnect_0.8.16 compiler_4.0.2 askpass_1.1 htmltools_0.5.0 openssl_1.4.2 knitr_1.29

最佳答案

添加 webshot图书馆解决了我的问题。
例如:

{r}
library(webshot)
DT::datatable(iris)
有趣的是,我在阅读了您的引用资料后尝试了这个解决方案。它就像一个魅力。谢谢你。

关于r - 如何让 webshot 与 bookdown 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62909485/

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