Search code examples
shinyr-markdownknitrflexdashboard

rmarkdown flexdashboard images folder deletes itself


My images folder deletes itself after first knitting of the document.

I've tried self_contained = TRUE in the YAML header, doesn't work.

(I'm not sure if this makes a difference but Shiny is embedded in the dashboard)

Below is my code :

---
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)
  }    
})

```

Solution

  • I think you have to do:

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