问题
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