1

This question was asked here and it was answered. However, now, it is not working for me. I am not sure if there is any changes in the package. Any ideas?

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="http://flaglane.com/download/american-flag/american-
            flag-large.png" height="52"></img>',
            '<img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/Flag_of_China.png" height="52"></img>'
 )
 )

  shinyServer(function(input, output){
   output$mytable <- DT::renderDataTable({

    DT::datatable(dat, escape = FALSE)
  })
})

Edits

My feeling was if it does not work in the Rstudio viewer, it would not work when I launch Shiny. However, I was wrong. When I run the app it works fine but in Rstudio Viewer, it does not.

library(shiny)
library(DT)


  dat <- data.frame(
  country = c('USA', 'China'),

  flag = c('<img src="http://flaglane.com/download/american-flag/american-
    flag-large.png" height="52"></img>',
       '<img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/Flag_of_China.png" height="52"></img>'
  )
   )
DT::datatable(dat, escape = FALSE)

enter image description here

Prradep
  • 5,049
  • 4
  • 37
  • 76
Fisseha Berhane
  • 2,210
  • 2
  • 25
  • 46

1 Answers1

1

Your example is incomplete. Does this work?

require(shiny)
library(DT)

ui <- shinyUI(
  DT::dataTableOutput('mytable')
)

dat <- data.frame(
  country = c('USA', 'China'),
  flag = c('<img src="http://flaglane.com/download/american-flag/american-flag-large.png" height="52"></img>',
           '<img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/Flag_of_China.png" height="52"></img>'
  )
)

server <- shinyServer(function(input, output){
  output$mytable <- DT::renderDataTable({
    DT::datatable(dat, escape = FALSE)
  })
})

shinyApp(ui, server)

It works fine for me.

parsley72
  • 7,617
  • 8
  • 64
  • 93
Florian
  • 23,130
  • 4
  • 44
  • 74