相关疑难解决方法(0)

如何使用DT,R和Shiny将图像嵌入到单元格中

如何在使用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)

r shiny shiny-server

12
推荐指数
1
解决办法
6264
查看次数

标签 统计

r ×1

shiny ×1

shiny-server ×1