I am having trouble displaying an image in a Shiny app. The code is saved in Desktop, where I also have a www folder with logo.png. I've set the working directory to the desktop, as well:
library(shiny)
library(png)
ui <- fluidPage(
img(src="logo.png", height = 400, width = 400)
) #close fluidpage
server <- function(input, output, session){
} # closer server
shinyApp(ui=ui, server=server)
Here's how the output looks.
I prefer to have server and ui in the same file for ease of understanding. Perhaps that is the issue?
It's just the image-display that is faulty. By default, RStudio searches in the 'www' folder. Try creating such a folder and place your image file in there. Make sure you still use the same path without 'www' for the src .
Adding Image To add an image in Shiny is done by using renderImage() function.
Similar Shiny img
problem solved here. Rather than executing the code directly or in console, creating a properly formatted app.R
and clicking Run App
seems to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With