如何加载外部图像到Shiny

Sau*_*han 3 r image shiny

在我当前的项目中,我尝试shiny dashboard使用R. 代码片段如下所示:

dashboardBody(
          hr(),
          fluidRow(
            column(6,align="center",imageOutput("ginger"))
          )
        )
      )

      server <- function(input, output) { 
        output$ginger <- renderImage({
          return(list(
            src = "images/ginger.jpg",
            contentType = "image/jpeg",
            width = 300,
            height = 200,
            alt = "Face"
          ))
        }, deleteFile = FALSE)
Run Code Online (Sandbox Code Playgroud)

基本上,它只是将图像显示在shiny dashboard. 这里图像存储在本地机器中。现在,我想从谷歌驱动器或网络加载图像。我正在尝试从我的谷歌驱动器加载图像,URL 是https://drive.google.com/file/d/0By6SOdXnt-LFaDhpMlg3b3FiTEU/view

我无法弄清楚如何从谷歌驱动器或网络加载图像以及如何在图像中添加标题? 我错过了什么吗?

And*_*ēza 6

这个答案很有启发性。这是一个准系统shiny应用程序,带有外部图像调用,用于显示您在 Google 云端硬盘帐户中提到的图像。

library(shiny)

# Define UI with external image call
ui <- fluidPage(
  titlePanel("Look at the image below"),

  sidebarLayout(sidebarPanel(),

                mainPanel(htmlOutput("picture"))))

# Define server with information needed to hotlink image
server <- function(input, output) {
  output$picture <-
    renderText({
      c(
        '<img src="',
        "http://drive.google.com/uc?export=view&id=0By6SOdXnt-LFaDhpMlg3b3FiTEU",
        '">'
      )
    })
}

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)