Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using webshot within knitr

Tags:

r

phantomjs

knitr

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.

like image 266
Eric Green Avatar asked Oct 18 '22 13:10

Eric Green


1 Answers

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

like image 108
Yihui Xie Avatar answered Oct 28 '22 21:10

Yihui Xie