R Brilliant output to the screen of an external image

I have a Shiny application that returns a character string containing the direct URL of an image posted on the Internet. I am trying to find a way to display this image directly as output.

When using renderImage () with src = "image url" the application does not display the image.

Here is an example of a problem:

ui.R

library(shiny)

shinyUI(fluidPage(
  headerPanel("render externally hosted Image example"),

  mainPanel(
   # Use imageOutput to place the image on the page
   imageOutput("myImage")
  )
))

server.R

library(shiny)

shinyServer(function(input, output, session) {
  output$myImage <- renderImage({
    list(src = "http://data-informed.com/wp-content/uploads/2013/11/R-language-logo-224x136.png",
     contentType = 'image/png',
     width = 224,
     height = 136,
     alt = "This is image alternate text")
  })
})

Any help is appreciated!

+4
source share
1 answer

You can use htmlOutput()in ui and renderText()on the server.

Server.r

src = "https://theWeb/aPictureSomewhere.jpg"
output$picture<-renderText({c('<img src="',src,'">')})

ui.r

htmlOutput("picture")
+5
source

All Articles