I have a web based OpenCPU application that (from the user's perspective) simultaneously provides both a tabular and graphical representation of model based forecasts.
The forecasts are driven by user-supplied input data (predictor/independent variables) taken from an html table. Calculations are then performed within R and the resultant data (response/dependent variables plus associated statistics) are used to both update the html table and feed the accompanying graphic.
My current solution is as follows:
ocpu.rpc
takes the user input, performs the calculations and passes back the table updates which are applied via JavaScript. Once these have been applied then…
ocpu.rplot
is engaged (as part of ocpu.rpc's callback function) to produce the corresponding graphic. (Note, it MUST take account of the updates – hence the callback).
Whilst the above solution works I can’t help but feel there's a more elegant solution…
For reasons of efficiency I'd like to process the input table and produce all tabular/graphical output in a singular R function call. This I can happily do, but my issue arises when I try to access both sets of output via JavaScript. Specificall:
- I'm struggling to see how I can retrieve the graphic having used
ocpu.rpc
. - I'm struggling to see how I can retrieve the table data having used
ocpu.rplot
. ocpu.call
appears to be the way forward as I can see both elements, namely ocpu/tmp/key/R/.val and ocpu/tmp/key/graphics/1... I can get hold of the table updates held in the former via the getObject() helper function but despite my efforts I'm having issues addressing the graphic.
Any help/advice would be much appreciated!