How to embed an image in a cell a table using DT, R and Shiny

前端 未结 1 970
不思量自难忘°
不思量自难忘° 2020-12-03 03:16

How can I embed an image in a cell that is generated using the DT package so that it is displayed in an app using shiny?

My example is based of this question R shiny

1条回答
  •  有刺的猬
    2020-12-03 04:21

    You can use the escape = FALSE in your DT call, as per: https://rstudio.github.io/DT/#escaping-table-content

    # 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('',
               ''
               )
    )
    
    shinyServer(function(input, output){
      output$mytable <- DT::renderDataTable({
    
        DT::datatable(dat, escape = FALSE) # HERE
      })
    })
    

    Images working with DT

    0 讨论(0)
提交回复
热议问题