0

I need your help for my R shiny application. I want to add a logo near the title in dashboardHeader. The logo don't display in the page. Can you help me ? Thanks in advance. This is the code :

library(shiny)
library(shinydashboard)

shinyApp(
  
  ui = dashboardPage(
    dashboardHeader(title = tags$img(src='logo.JPG', height = '60', width ='60')),
    dashboardSidebar(),
    dashboardBody()
),
server = function(input, output) {}
)
Pinkette
  • 5
  • 2

2 Answers2

2

Just create a new folder with the name "www" in the same directory as your script and add your picture in that

Mriti Agarwal
  • 204
  • 1
  • 7
1

Your code seems to work just fine. Try this for example with an image from the internet(I just put google as an example).

library(shiny)
library(shinydashboard)

shinyApp(
  
  ui = dashboardPage(
    dashboardHeader(title = tags$img(src='https://cdn.vox-cdn.com/thumbor/Ous3VQj1sn4tvb3H13rIu8eGoZs=/0x0:2012x1341/1400x788/filters:focal(0x0:2012x1341):format(jpeg)/cdn.vox-cdn.com/uploads/chorus_image/image/47070706/google2.0.0.jpg', height = '60', width ='60')),
    dashboardSidebar(),
    dashboardBody()
  ),
  server = function(input, output) {}
)

Jack
  • 126
  • 1
  • 2
  • 9
  • 1
    Hi @Jack, thanks for your response. It is work with a picture from the website but when I want to display it from a picture inside of the same folder that isnt display. I dont know why :/ – Pinkette Sep 24 '20 at 13:06
  • Try putting your image in a separate 'www' folder which is in the same directory as your app.R – Jack Sep 24 '20 at 13:08
  • It is explained in more detail here under the 'Images' section: http://shiny.rstudio-staging.com/tutorial/written-tutorial/lesson2/ – Jack Sep 24 '20 at 13:10
  • I am getting the same issue as @Pinkette here. Did you manage to resolve it? I've got an image saved in the "www" folder, so the code looks like `tags$img(src = "www/image.png")`, but this doesn't work. – Dmitry Ishutin Feb 22 '22 at 12:23