R Shiny img() on UI side does not render the image

£可爱£侵袭症+ 提交于 2020-12-08 13:22:27

问题


I have a static image in the local folder I am trying to render in the Shiny UI and it does not work. Shows a broken image with a question mark in the middle.

ui <- fluidPage(img(src = 'imagefile.png', height = '100px', width = '100px'))
server <- function(input, output) {}
shinyApp(ui = ui, server = server)

Any idea what is going on?


回答1:


Put the image in a folder called www in the same directory, so you have www/imagefile.png. Then, call

library(shiny)
ui <- fluidPage(img(src = 'imagefile.png', height = '100px', width = '100px'))
server <- function(input, output) {}
shinyAppDir(".")

But, you probably want to be using runApp with a separate ui and server file.



来源:https://stackoverflow.com/questions/35760656/r-shiny-img-on-ui-side-does-not-render-the-image

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