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,506
  • 5
  • 43
  • 84
Fisseha Berhane
  • 2,533
  • 4
  • 30
  • 48

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
  • 8,449
  • 8
  • 65
  • 98
Florian
  • 24,425
  • 4
  • 49
  • 80