2017-07-24 82 views
2

我想使用tableHTML在閃亮的UI單元格中顯示圖像。但是,它只是顯示文本。任何幫助?tableHTML閃亮:在單元格中顯示圖像

library(shiny) 
a = data.frame(rows = 1:2, icons = '<img src = 
    "http://flaglane.com/download/american-flag/american-flag-graphic.png" 
    alt="Red Flag Warning" height="30" width="40" >') 



    shinyApp(
    ui = fluidPage(
     fluidRow(

    br(), 
    column(width = 1), 
    tableHTML_output("mytable")) 
    ), 
server = function(input, output) { 
    output$mytable <- render_tableHTML( 
    tableHTML(a) 
)} 
) 

這是在我運行的代碼顯示的內容: enter image description here

回答

3

這是一個known issuetableHTML,這是由於固定在下一版本中。暫且(你的鏈接似乎並不指向圖片,所以我將使用一個來自w3school),你可以使用這個:

library(shiny) 
library(tableHTML) 
a = data.frame(rows = 1:2, icons = '<img src = 
       "https://www.w3schools.com/images/w3schools_green.jpg" 
       alt="Red Flag Warning" height="30" width="40" >') 



shinyApp(
ui = fluidPage(
    fluidRow(

    br(), 
    column(width = 1), 
    tableHTML_output("mytable")) 

), 
server = function(input, output) { 
    output$mytable <- render_tableHTML( 
    tableHTML(a) %>% 
    replace_html(pattern = '&#60;', '<', replace_all = TRUE) %>% 
    replace_html(pattern = '&#62;', '>', replace_all = TRUE) 
)} 
) 

輸出:

enter image description here

相關問題