I want to create a table with images in header row, each image is a hyperlink to another landing page with popover once mouse rollover it.
I need to make the 1st column in each row contains text also hyperlinked to a new landing page.
Asked
Active
Viewed 72 times
1

A. Suliman
- 12,923
- 5
- 24
- 37

Ahmed Gondy
- 91
- 1
- 6
1 Answers
2
Here is one option using DT and based on Brandon Bertelsen's answer here
dat <- data.frame(
`<a href="https://en.wikipedia.org/wiki/China"><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" title="China"></img></a>` = c('1234','23456'),
check.names = FALSE,
row.names = c('<a href="https://en.wikipedia.org/wiki/Gross_domestic_product">GDP</a>', "Population"))
DT::datatable(dat, escape = FALSE)
See here for more info about creating HTML Image Link and HTML text link.

A. Suliman
- 12,923
- 5
- 24
- 37
-
Thanks for your quick reply, I've tried this but it's not working, – Ahmed Gondy Jul 28 '19 at 18:55
-
@AhmedBaghdadi to get a nice cell's format check https://rstudio.github.io/DT/functions.html but you may need to transpose your dataframe. Or you can try this https://stackoverflow.com/questions/53784955/r-formatting-by-row-using-dt – A. Suliman Jul 28 '19 at 19:16
-
and how can i add pop over on the flag to mention "China" before clicking ? – Ahmed Gondy Jul 28 '19 at 19:29
-
@AhmedBaghdadi add `title="China"` after the height attribute inside the _img_ tag. see my update. – A. Suliman Jul 28 '19 at 19:35
-
If this answer is ok for you, you can mark it as the answer. :) – phili_b Jul 29 '19 at 07:48
-
Dear @A.Suliman, could you support with this https://stackoverflow.com/questions/31375480/using-observe-function-in-shiny-r – Ahmed Gondy Aug 11 '19 at 23:14
-
@AhmedGondy I'll be happy to help but please open a new question "[Minimal, Complete, and Verifiable example](https://stackoverflow.com/questions/48343080/how-to-convert-a-shiny-app-consisting-of-multiple-files-into-an-easily-shareable)" and linked to alloyeduniv's question if it helps to provide the context or add additional information. – A. Suliman Aug 12 '19 at 10:49