【问题标题】:using webshot within knitr在 knitr 中使用 webshot
【发布时间】:2016-03-16 17:49:39
【问题描述】:

在尝试为this SO question 寻找关于保存d3heatmap 生成的热图的解决方案的过程中,我在development version of knitr 中使用webshot 遇到了一个不相关的问题(HT:hrbrmstr)。

library(devtools)
devtools::install_github('yihui/knitr', build_vignettes = TRUE)
library(knitr)

安装并加载knitr的开发版后,我尝试运行以下.Rmd文件:

---
title: "Untitled"
output: pdf_document
---

```{r}
library(d3heatmap)
d3heatmap(mtcars, scale = "column", colors = "Spectral")
```

系统提示我安装 phantomjs:

webshot::install_phantomjs()

phantomjs.exe has been installed to /Users/USERNAME/Library/Application Support/PhantomJS

我尝试再次运行.Rmd 文件,但出现此错误:

sh: ~/Library/Application Support/PhantomJS/phantomjs: No such file or directory
Quitting from lines 7-9 (test.Rmd) 
Error in (function (url = NULL, file = "webshot.png", vwidth = 992, vheight = 744,  : 
  webshot.js returned failure value: 127
Calls: <Anonymous> ... html_screenshot -> in_dir -> do.call -> <Anonymous>
Execution halted

我相信错误告诉我 R 找不到 phantomjs.exe,但我看到它位于指定的路径中。我知道这尖叫着愚蠢的用户错误。

【问题讨论】:

    标签: r phantomjs knitr


    【解决方案1】:

    这是一个known bug,已在当前development version of webshot 中修复。

    【讨论】:

    • 太棒了,@Yihui。我可以确认我能够使用knitr 的开发版本运行该文件,具体取决于webshot 的开发版本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2015-10-07
    • 2014-08-17
    相关资源
    最近更新 更多