首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rmarkdown:在R更新后无法使用knitr::include_graphics插入图像

Rmarkdown:在R更新后无法使用knitr::include_graphics插入图像
EN

Stack Overflow用户
提问于 2019-08-16 06:58:25
回答 2查看 912关注 0票数 1

在更新了R和RStudio以及所有包之后,我正在尝试呈现和旧的rmarkdown文件,但是我得到了:

代码语言:javascript
复制
Error: pandoc document conversion failed with error 99

然而,这条路是正确的。我昨天已经呈现给HTML了,一切都很好。

代码语言:javascript
复制
```{r, echo=FALSE, fig.cap="", out.width = '50%', fig.align='center'}

knitr::include_graphics("/img/posts/que-es-un-api/mastercard-blockchain-api.jpg")

代码语言:javascript
复制

它说到图像的路径是错误的,但希望您可以从图像路径是正确的。

代码语言:javascript
复制
"C:/PROGRA~1/Pandoc/pandoc" +RTS -K512m -RTS que-es-un-api.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output que-es-un-api.html --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\OGONZALES\Documents\R\win-library\3.6\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\OGONZA~1\AppData\Local\Temp\RtmpSsSNeA\rmarkdown-str1340bc36ef.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 
File /img/posts/que-es-un-api/mastercard-blockchain-api.jpg not found in resource path
Error: pandoc document conversion failed with error 99
Execution halted

我甚至尝试用以下方法重新安装Pandoc:

代码语言:javascript
复制
# installing/loading the package:
if(!require(installr)) { install.packages("installr"); require(installr)} #load / install+load installr

# Installing pandoc
install.pandoc()

sessionInfo:

代码语言:javascript
复制
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  htmltools_0.3.6 tools_3.6.1     yaml_2.2.0      Rcpp_1.0.2     
 [6] rmarkdown_1.14  knitr_1.24      xfun_0.8        digest_0.6.20   evaluate_0.14 
EN

回答 2

Stack Overflow用户

发布于 2019-08-18 20:48:26

也许工作目录被更改了。试着包括整个路径:

代码语言:javascript
复制
```{r, echo=FALSE, fig.cap="", out.width = '50%', fig.align='center'}

knitr::include_graphics("D:/omargonzalesdiaz/static/img/posts/que-es-un-api/mastercard-blockchain-api.jpg")

代码语言:javascript
复制
票数 0
EN

Stack Overflow用户

发布于 2022-02-09 17:56:24

我们讨论了这里这里这两个问题,它们本身并不是一个bug。对我有效的解决办法是使用:

代码语言:javascript
复制
```{r example, echo = FALSE, out.width='80%', out.height='50%'}

knitr::include_graphics(paste0(getwd(),“/映像/示例_Image.png”))

代码语言:javascript
复制

如果您在Rstudio项目中工作,那么首先指定目录将有所帮助:

代码语言:javascript
复制
```{r example, echo = FALSE, out.width='80%', out.height='50%'}

Rprojroot::find_rstudio_root_file()

knitr::include_graphics(paste0(getwd(),“/映像/示例_Image.png”))

代码语言:javascript
复制

这里这里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57520181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档