2
我试图在本地路径的数据表中显示图像。请注意,本地路径与www文件夹不同,在实际情况下,我无法将图像从指定路径移动到www文件夹。奇怪的是,它是从www的位置开始工作,而不是从规定的路径开始工作。寻找任何提示来解决这个问题。从R中的本地路径显示数据表中的图像Shiny
下面是代码:
library(shiny)
library(shinyBS)
library(DT)
flag <- data.frame(image=c('<img src="C:/Users/string/100x100/100x100_bigimg.jpg"></img>'))
ui <- shinyUI(pageWithSidebar(
headerPanel("renderImage example"),
sidebarPanel(
actionButton("go","Go")
),
mainPanel(
bsModal("modalExample", "Image", "go", size = "large",imageOutput("myImage")),
DT::dataTableOutput("dt")
)
))
server <- shinyServer(function(input, output, session) {
output$dt <- DT::renderDataTable({
DT::datatable(flag,escape = FALSE)
})
observeEvent(input$go,{
output$myImage <- renderImage({
# Return a list containing the filename
return(list(src = "C:/Users/string/100x100/100x100_bigimg.jpg",
contentType = 'image/png',
width = 550,
height = 400,
alt = "This is alternate text"))
}, deleteFile = FALSE)
})
})
shinyApp(ui,server)
另外,从规定路径renderImage部分工作完美,但在数据表部分图像是没有得到显示。