Reputation: 85
I am using R to generate an image (png file). How do I use shiny to render it to the ui?
source("#rasterBasePlot.R")
output$spatialMap <- renderImage ({
filename <- PNGFileName
# Return a list containing the filename
list(src = filename)
}, deleteFile = TRUE)
Upvotes: 1
Views: 340
Reputation: 33540
You can simply create a www
folder inside your app folder and put the images you want to display there. After that something like the following should be sufficent:
library(shiny)
ui <- fluidPage(
tags$img(
src = "/myimage.png", width = 100
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
If you want to use folders other than www
you can use addResourcePath
to add resources to Shiny's web server. Please see this.
Upvotes: 1