I'd like to make a Rmarkdown report, and use a function to encapsulate making of multiple grouped dygraph charts. I cannot figure out how to have all of the charts rendered when called from within a function. The following snippet only renders only the last of the two dygraph plots I create. I am looking for how I display both plots in the ensuing markdown by calling the function foo().
I have an answer/response below that gets most of the way there, but I cannot figure out how to control the height/width appropriately, which is laid out there.
This isn't quite right. The plots to not shrink, but they do overlap each other in the positions that would be right (they are just not scaled to be right height and width). Help on this part appreciated. EDIT: It looks you have to control this directly in the dygraph() call, and I have updated this code to reflect this. I've left the (now unhelpful) map call to wrap this in a div element in case that is useful to others if that changes other things.