1

I feel like there is really silly mistake, but I can't solve this myself and it is driving me crazy. To simply put, Rshiny is not display the image.

I put the source image in www directory in same path as the Rscript file, yet something is wrong.

The code I used are below:

ui <- fluidPage(
  fluidRow(
    titlePanel(title=div(img(height = 100,
                             width = 100,
                             src = "dummy-logo.png"), "dummy")),
    sidebarLayout(...

This is the pathway for my image.

enter image description here

Here is the directory.:

enter image description here

Yet Rshiny could not find the image:

enter image description here

I looked around other posts but I am still not sure where I went wrong. I am pretty sure this is some really dumb mistake that I will be ashamed of but as of now, it is driving me nuts. Thank you.

aiorr
  • 547
  • 4
  • 11
  • I don't see an .Rproj file in the directory, are you sure that this is the working directory your app is starting from? – mlegge Apr 29 '18 at 23:10
  • 1
    Try the full path. Then see if you can use `~/`. The path for the assets in Shiny (or knitr) is not necessarily what you think. – Elin Apr 29 '18 at 23:45
  • How do you run your shinyapp ? By executing your code as if it was a classical code (sourcing from the terminal for example) or using the Run App button in RStudio ? – kluu Apr 30 '18 at 12:03
  • I am running by Run App button in RStudio. – aiorr Apr 30 '18 at 21:12

1 Answers1

2

Have you checked this answer? Embedding Image in Shiny App

Maybe rewrite the titlePanel to:

titlePanel(title=div(id="dummy", img(height = 100,
                         width = 100,
                         src = "dummy-logo.png"))),

And check if the image is really named - dummy-logo.png.

Otherwise i would suggest you create a New Project in RStudio -> New Directory -> Shiny Web Application. Put your ui and server functions in there. Create the www-folder, put your image in there and it should work like that.

SeGa
  • 9,454
  • 3
  • 31
  • 70
  • This is what I did. I just deleted my entire folder and file and made new project/directory. Although it is kind of brute way to solve it, your second suggestion indeed work. – aiorr May 25 '18 at 21:10
  • I've had a similar strange problem. Solved it be renaming my 'app.R' file to 'app' which my Mac automatically puts a '.R' on the end, then it worked fine. – Tony Ladson May 22 '19 at 23:47