lhatcher1986 lhatcher1986 - 1 year ago 99
R Question

R: Hover Event in Shiny App

I have a datatable within a Shiny app containing thousands of records and 10 fields. One of the fields, 'Notes', contains the body of a unique email sent to each record. Due to the size of some of the emails, it takes up a lot of room in the datatable. I would like to create an info icon for each row that when hovered over will display the email associated with that row in a popup window which will subsequently go away after moving the mouse off of the icon. Is this possible in Shiny?

Answer Source

Yes. First, you'll need to process that email text as HTML and add the following tags:

<i class='fa fa-info-circle' data-toggle='tooltip' data-placement='right' title='YOUR EMAIL TEXT'></i>

Depending on the size of your email, that tooltip might become a bit heavy, but this does what you want it to do.

Note that this is assuming you're running shinyDashboard (although I think any of the options - fluidPage, navbarPage etc - will work).

You also need to set escape = FALSE in datatable(x, escape = FALSE)

You can have a look at this implementation. For a table demo, click on GO, then click on the 'Health Behaviors' tab.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download