rstudio / rstudio/flexdashboard

`renderUI` can't find local images when using `flexdashboard`

Open
#439 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
848
Forks
298
PR merge metrics
No merged PRs in 30d

Description

I have a shiny app that begins with a series of instructions that are conditional on the input that a user selects. I want to include both text and a local image as part of the instructions. renderUI seems to be unable to locate the local image. include_graphics displays the image as expected, but I can not make it conditional on the input that the user selects.

---
title: "MyApp"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Sidebar {.sidebar}
=====================================

```{r}
selectInput("input_type", 
            label = "Select an input",
            choices = list(" "=1,
                           "Input 1" = 2,
                           "Input 2" = 3))
```


MyApp
=====================================

Row {.tabset}
-----------------------------------------------------------------------

### img src

```{r}
renderUI({
  
  input_type <- input$input_type
  
  if (input_type == 1) {
    HTML('Welcome to my app! Here are some instructions about how to use it. 
A helpful image will appear when you select an input.')} 
  
  else if (input_type == 2) {
    HTML('Here are some instructions.
         <div><img src = "Posit_1.png"></div>')
  } 
  
  else if (input_type == 3) {
    HTML('Here are some other instructions. 
         <div><img src = "RStudio_2.png"></div>')
  }
  
})
```

### include_graphics

```{r}
knitr::include_graphics("Posit_1.png")
knitr::include_graphics("Rstudio_2.png")
```
image image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the flexdashboard app shown in the issue, comparing renderUI with knitr::include_graphics. Trace how flexdashboard serves local assets through these two paths; done means the conditional Posit_1.png and RStudio_2.png images render for selections 2 and 3 while selection 1 still shows its text.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.