Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created June 24, 2013 19:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ramnathv/f476dd3751e672a96801 to your computer and use it in GitHub Desktop.
Save ramnathv/f476dd3751e672a96801 to your computer and use it in GitHub Desktop.
Images in Tables in Shiny
require(shiny)
shinyServer(function(input, output){
output$mytable <- renderTable({
dat <- data.frame(
country = c('USA', 'China'),
flag = c('<img src="http://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/200px-Flag_of_the_United_States.svg.png"></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"></img>')
)
dat
}, sanitize.text.function = function(x) x)
})
require(shiny)
shinyUI(
tableOutput('mytable')
)
@mikejruane
Copy link

sorry, I realise that, if adding the desired variable pic to the html code above would return "value-of-pic.JPG.JPG", but I'm sure it doesn't work with the correction "Work = '' for the reasons stated above.

Thanks,

Mike

@mikejruane
Copy link

Hi there,

I managed to solve this with the qq function, a Perl like function in the GetoptLong package on variable interpolation within text strings.

Thanks,

Mike

@ulwvfje
Copy link

ulwvfje commented Mar 8, 2016

it's really helpful for me , Thank you so much

@GaborSzalai
Copy link

Thanks a lot! Great trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment