- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 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.
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:
webshot
和
phantomjs
按照这些说明下载并安装,这很容易确认:
> 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
所以...如果
webshot
和
phantomjs
似乎已安装...我做错了什么?
> 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/
我是一名优秀的程序员,十分优秀!