在我的当前项目中,我试图使用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)
基本上,它只是在shiny dashboard
上显示图像。在这里,图像存储在本地机器中。现在,我想从谷歌驱动器或网络加载图像。我试图从我的谷歌驱动器和网址是https://drive.google.com/file/d/0By6SOdXnt-LFaDhpMlg3b3FiTEU/view的图像加载。
我想不出如何从google驱动器或网页加载图片,以及如何在图片中添加标题?,我是不是遗漏了什么?
发布于 2017-04-10 04:13:02
This answer是有教育意义的。这是一个简单的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)
https://stackoverflow.com/questions/43322327
复制