using webshot within knitr
Asked Answered
Z

1

7

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.

Zacheryzack answered 16/3, 2016 at 17:49 Comment(0)
G
3

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

Ghislainegholston answered 16/3, 2016 at 21:24 Comment(1)
great, @Yihui. I can confirm that I was able to run the file with development version of knitr depending on the development version of webshot.Zacheryzack

© 2022 - 2024 — McMap. All rights reserved.