2

I would like to include a local image file in my shiny app, following these instructions:

Embedding Image in Shiny App

However, my IT networks security, for some reason, prevents R from reading that image.

  • I can confirm it is an IT security blockage, because the same exact code and file/directory structure works when I move to another computer.
  • It is also strange, because I am able to read other files from that folder, because other commands like read.csv() are not blocked. I dont know what subroutines go on inside img(src()) but my network does not like it.

Any alternative ways to embed an image in a shiny app ui?

Lee88
  • 1,185
  • 3
  • 15
  • 27

1 Answers1

10

Maybe with base64 encoding:

b64 <- base64enc::dataURI(file="myfile.png", mime="image/png")

ui <- fluidPage(
 img(src=b64)  
)

server <- function(input, output) {

}

shinyApp(ui = ui, server = server)

Where myfile.png is in the same folder as the app.

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225