我想使用tableHTML在闪亮的UI单元格中显示图像。但是,它只是显示文本。有什么帮助吗?
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)
)}
)
答案 0 :(得分:3)
这是一个known issue tableHTML
,它将在下一个版本中修复。暂时(你的链接似乎没有指向图片所以我将使用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 = '<', '<', replace_all = TRUE) %>%
replace_html(pattern = '>', '>', replace_all = TRUE)
)}
)
输出: