put image in shiny App

Viewed 7353

I'm trying to put an Image into shiny app. I have created a folder called www at the same working directory of my shiny app and put a png photo there, using the following code should show the image :

library(shiny)

ui <- fluidPage(

tags$img(src='photo.png'))


server <- function(input,output){}

shinyApp(ui=ui, server=server)

But instead I have this :

enter image description here

Am I missing something ?!!!

2 Answers

I'm not sure if you're still looking for this answer, but if any new users are: You need to create a directory in your folder called www. Place the image there. In your ui.R file, use img("myImage.png").

First make sure you have set your working directory. You may use the setwd("") command at the top of your script. Next create a folder called www. This needs to be in your working directory (i.e. the folder where you save your app.R). Put the image file in that folder.

Related