Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put entire image location in tags$img of shiny package?

Tags:

r

shiny

The following code for tags$img is:

  • Working...when the image is stored in 'www' folder and src = "Rlogo.png"
  • Not working...when entire path of the image is given

I need to put the entire location in one of my shiny app where the app.R file will be run from command prompt. Please help thanks..

library(shiny)

ui <- fluidPage(
  box(
    tags$img(height = 100, width = 100,src = "Rlogo.png"),
    tags$img(height = 100, width = 100,src = "E:/myApp/www/Rlogo.png")
  )
)

server <- function(input, output, session) {

}

shinyApp(ui, server)

enter image description here

like image 747
Raja Saha Avatar asked Sep 09 '25 23:09

Raja Saha


1 Answers

use imageOutput instead of tags$img:

library(shiny)

ui <- fluidPage(
    box(
        tags$img(height = 100, width = 100,src = "Rlogo.png"),
        imageOutput('image')
    )
)

server <- function(input, output, session) {
    output$image <- renderImage({
            list(src = "E:/myApp/www/Rlogo.png",
                 alt = "This is alternate text"
            )
        }, deleteFile = TRUE)
}

shinyApp(ui, server)
like image 145
Hamed Yazarloo Avatar answered Sep 12 '25 14:09

Hamed Yazarloo