local image in shiny app without img(src())?

别说谁变了你拦得住时间么 提交于 2021-02-10 15:14:22

问题


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?


回答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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!