rmarkdown flexdashdash images文件夹会自行删除

时间:2019-02-27 18:58:24

标签: shiny r-markdown knitr flexdashboard

我的图像文件夹在第一次编织文档后即自动删除。

我在YAML标头中尝试了self_contained = TRUE,不起作用。

(我不确定是否会有所作为,但Shiny嵌入在仪表板中)

下面是我的代码:

---
title : app demo
author : yeshipants
output : 
  flexdashboard::flex_dashboard:
    orientation: rows
    self_contained : TRUE
    source_code: embed
runtime: shiny
---

```{r setup}
knitr::opts_chunk$set(cache = FALSE)
```
```{r loadPackages, cache = TRUE}  
setwd("C:/Users/user/Desktop/Training/OCR")
library(magick)
```
Column {.sidebar data-width=350}
-------------------------------------
### Input & Parameters
```{r inputImages, cache = TRUE}

selectInput("imagesToChoose", 
            label = "Choose an image to process",
            choices = c("Language example 1", 
                        "Language example 2",
                        "Jounal example"),
            selected = "Language example 1") 
```
Row {.tabset}
-------------------------------------  
### Original Image    
```{r displayImage, cache = FALSE}    
renderImage({      
  if (input$imagesToChoose == "Language example 1"){
    list(src = "images/receipt.png", height = 240, width = 300)
  }
  else if(input$imagesToChoose == "Language example 2"){
    list(src = "images/french.JPG", height = 240, width = 300)
  }
  else if(input$imagesToChoose == "Jounal example"){
    list(src = "images/journal.jpg", height = 240, width = 300)
  }    
})

```

1 个答案:

答案 0 :(得分:1)

我认为您必须这样做:

renderImage({      
  ......
}, deleteFile = FALSE)