Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image not showing in Shiny app R

Tags:

r

image

shiny

I have an image i'd like to embed into my shiny app, and have read as much as I can find on how to do it. Although, all I get is a blue question mark when I run my code.

This is the line of code I have added, within the fluidPage ui command

img(src="logo.png", align = "right",height='100px',width='400px')

My image has been placed in the project directory folder, as well as trying in a separate folder inside named www (as per suggestion given here)

EDIT: Code used in the following context:

ui <- fluidPage(titlePanel("Test title"),

                img(src="logo.png", align = "right",height='100px',width='400px'),

                hr())
like image 381
sym246 Avatar asked Jun 24 '16 10:06

sym246


People also ask

How do I make my picture Shiny in the app?

12.1 Adding an Image To include the image in your App, you'll need to make use of the image tag, img . When you run your App, Shiny automatically knows to check the www folder any time the img tag gets called.


2 Answers

After coming back to this problem, I found that the solution is to simply format the Shiny code properly, by naming the R file app.R, and clicking Run App as opposed to selecting all of the code and running within the console.

Not sure how or why this makes a difference, but the numerous Shiny applications I have worked on since have all been resolved when doing this.

like image 199
sym246 Avatar answered Sep 29 '22 19:09

sym246


I was having the same problem. To solve this, just create a folder named 'www' in the same folder as your app.R script and put the images within that folder.

I found the solution to this problem in the tutorial video in this page: Shiny Tutorial Video - Adding Static Content Watch from 1h45min00sec.

like image 41
gurezende Avatar answered Sep 29 '22 20:09

gurezende