在knitr中使用webshot [英] using webshot within knitr

查看:97
本文介绍了在knitr中使用webshot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试找到有关此保存问题的此SO问题的过程中d3heatmap产生的热图,我在webshot遇到了不相关的问题> knitr 的开发版本(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,但我发现它位于指定的路径中.我知道这会响起愚蠢的用户错误.

解决方案

这是已知错误,并且已在 webshot 的当前开发版本中进行了修复. /p>

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.

解决方案

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

这篇关于在knitr中使用webshot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆