Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderUI can't find local images when using flexdashboard #439

Open
melissagwolf opened this issue Sep 2, 2023 · 0 comments
Open

renderUI can't find local images when using flexdashboard #439

melissagwolf opened this issue Sep 2, 2023 · 0 comments

Comments

@melissagwolf
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant