问题
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 insideimg(src())
but my network does not like it.
Any alternative ways to embed an image in a shiny app ui?
回答1:
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.
来源:https://stackoverflow.com/questions/50073559/local-image-in-shiny-app-without-imgsrc