using webshot within knitr

与世无争的帅哥 提交于 2019-12-12 11:38:51

问题


In the process of trying to find a solution to this SO question about saving a heatmap produced by d3heatmap, I encountered an unrelated problem using webshot within the development version of knitr (HT: hrbrmstr).

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

After installing and loading the development version of knitr, I tried running the following .Rmd file:

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

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

I was prompted to install phantomjs:

webshot::install_phantomjs()

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

I tried running the .Rmd file again, but I got this error:

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

I believe that the error is telling me that R can't find phantomjs.exe, but I see that it's located in the specified path. I know this screams stupid user error.


回答1:


This is a known bug and has been fixed in the current development version of webshot.



来源:https://stackoverflow.com/questions/36043244/using-webshot-within-knitr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!