【问题标题】:ioslides presentation doesn't render png image fileioslides 演示文稿不呈现 png 图像文件
【发布时间】:2015-11-24 07:49:54
【问题描述】:

下面是一个小型 ioslides 演示文稿,其中一张幻灯片中嵌入了闪亮的应用程序。另一张幻灯片尝试显示 png 图像文件。 当我在 RStudio 中“运行演示文稿”时,png 图像不会呈现,并且我收到警告:

file.create(to[okay]) 中的警告: 无法创建文件'C:\Users\John\AppData\Local\Temp\Rtmpkty0sF\file3b247a612422_files/C:/Develop/data/smile.png',原因'无效参数'

如果我删除了闪亮的代码,并从 YAML 中删除了“运行时:闪亮”,那么 png 图像会正确呈现,而不会发出警告。在这种情况下,RStudio 显示了一个“编织”演示文稿的按钮,而不是闪亮应用程序的“运行演示文稿”。

此处报告了类似的问题:

ioslides css and logo

这里:

Error adding images in ioslides

这是我的设置: 视窗 9, RStudio 版本 0.99.473, 包:rmarkdown 版本:0.7.3, 包:闪亮版本:0.12.2.9001, 包:httpuv 版本:1.3.3,

这是我的 RMarkdown 代码:

---
title: "ioslides Presentation with Shiny"
author: "John Doe"
date: "August 27, 2015"
output: 
  ioslides_presentation: 
    widescreen: true
    smaller: true
    transition: 0.1
    self_contained: true
runtime: shiny
---

## Slide with Embedded Inline Shiny Application

Below is an embedded inline shiny application:
```{r, echo=FALSE}
inputPanel(
  selectInput("n_breaks", label = "Number of bins:",
              choices = c(10, 20, 35, 50), selected = 20),

  sliderInput("bw_adjust", label = "Bandwidth adjustment:",
              min = 0.2, max = 2, value = 1, step = 0.2)
)

renderPlot({
  hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
       xlab = "Duration (minutes)", main = "Geyser eruption duration")

  dens <- density(faithful$eruptions, adjust = input$bw_adjust)
  lines(dens, col = "blue")
})
```

## Slide With a Smiling Face

![smiling_face](C:/Develop/data/smile.png)

【问题讨论】:

    标签: r shiny rstudio r-markdown pandoc


    【解决方案1】:

    JJ Allaire(RStudio 的 CEO!)在 GitHub 上提供了答案:
    jjallaire answers

    我将总结说,如果 ioslides 演示文稿包含嵌入式闪亮应用程序,则它要求图像文件存储在与 .Rmd 文件相同的目录中,或者存储在子目录中,而不是单独的目录分支中。应使用相对文件路径而不是绝对路径来引用图像文件。这是因为当 ioslides 演示文稿被编织(解析)时,它们被存储为一个包含 .js 和其他文件的目录,并且所有图像都必须复制到该目录中。硬编码绝对文件路径可防止 RStudio knitr 复制图像文件。

    我将图像文件复制到“图像”子目录,并将我的 rmarkdown 代码更改为这个,现在它可以工作了:

    ![smiling_face](image/smile_small.png)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-01
      • 2014-07-30
      • 2014-05-17
      • 2016-07-17
      相关资源
      最近更新 更多