Cross talk across multiple data frames?

341 views
Skip to first unread message

Ahsan Shah

unread,
Apr 1, 2017, 11:06:14 AM4/1/17
to Shiny - Web Framework for R
Hi,

Crosstalk looks very cool and I had a general question.  If I have data sets that are of different granularities (e.g summary level vs detail)...I assume to use crosstalk I would need to merge them to a single dataframe to prep for crosstalk?  For instance, if I have a dataframe with values for each DATE but on any given DATE I have a set of N "Events" I would ideally like to show those events filtered as I filter on DATE.  One approach I was thinking is to use tidyr to merge/spread the data so that each "Event" is a column but I could easily see this going out of control.

So the question is, if I have a Shiny Dashboard with 2 grains of data, is there a way to integrate both to crosstalk somehow?  Perhaps 2 sets of CROSSTALK widgets and a Shiny Reactive which joins the two?  Or is there a more elegant way to do this.  Could I perhaps use a List within a Dataframe?  

Any advice is appreciated.


Joe Cheng

unread,
Apr 4, 2017, 7:37:47 PM4/4/17
to Ahsan Shah, Shiny - Web Framework for R
There's not an easy way to do this for now--it's one of the biggest limitations of Crosstalk. If you're writing your own custom widget then it should be straightforward for you to take the entire (fine granularity) dataframe and do the aggregation in JavaScript... but this doesn't feel to me like a generalizable solution. Or at least, it's a heavy price to pay for the average htmlwidget.

Although... using Shiny... that's interesting. Yes, that might be possible with two observers, one looking at each SharedData object and reflecting the selection changes onto the other...

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/e69533be-3b73-4cb0-82c3-b6912e1aedf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahsan Shah

unread,
Apr 6, 2017, 10:07:20 PM4/6/17
to Shiny - Web Framework for R
Thanks for the input. Will try out the approach with 2 observers.

dhiraj khanna

unread,
Sep 11, 2018, 2:12:46 AM9/11/18
to Shiny - Web Framework for R
Hi Ahsan,
Working on a very similar issue. I have two totally unrelated dataframes. One shows the location of ships and the other one shows the oil prices at different ports. I am using `addMarkers()` to plot this data as separate layers. Currently if I use just the first dataframe which has the ship locations, crosstalk works. However, as soon as I add the second layer of markers, crosstalk obviously doesn't work as the data is not shared.

Were you able to do this in Shiny as suggested by Joe using two observers?
Reply all
Reply to author
Forward
0 new messages