Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r Shiny: renderImage from www

Tags:

r

shiny

renderImage isn't working when trying to render an image from the internet. It works when the image is on the local machine.

  output$myImage <- renderImage({
    pfad <- "https://www.rstudio.com/wp-content/uploads/2014/03/blue-125.png"
    list(src = pfad,
         contentType = 'image/png',
         width = 400,
         height = 300,
         alt = "This is alternate text")
  }, deleteFile = F)


imageOutput("myImage")
like image 500
Shen Avatar asked Apr 13 '16 13:04

Shen


1 Answers

You can use tags$img directly in the ui or in a reactive context :

library("shiny")
ui <- fluidPage(
  fluidRow(
    column(
      6,
      tags$img(src = "https://www.rstudio.com/wp-content/uploads/2014/03/blue-125.png")
    ),
    column(
      6,
      uiOutput(outputId = "image")
    )
  )
)
server <- function(input, output) {
  output$image <- renderUI({
    tags$img(src = "https://www.rstudio.com/wp-content/uploads/2014/03/blue-125.png")
  })
}
shinyApp(ui = ui, server = server)
like image 133
Victorp Avatar answered Oct 17 '22 10:10

Victorp