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部分工作完美,但在數據表部分圖像是沒有得到顯示。