如何在使用DT包生成的单元格中嵌入图像,以便使用闪亮的应用程序显示?
我的例子是基于这个问题R闪亮:我如何将本地图像放在闪亮的表格中
下面的示例代码不显示图像,而只显示网址.
# ui.R
require(shiny)
library(DT)
shinyUI(
DT::dataTableOutput('mytable')
)
# Server.R
library(shiny)
library(DT)
dat <- data.frame(
country = c('USA', 'China'),
flag = c('<img src="test.png" height="52"></img>',
'<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Flag_of_the_People%27s_Republic_of_China.svg/200px-Flag_of_the_People%27s_Republic_of_China.svg.png" height="52"></img>'
)
)
shinyServer(function(input, output){
output$mytable <- DT::renderDataTable({
DT::datatable(dat)
})
})
Run Code Online (Sandbox Code Playgroud)