質問

I am using OpenCPU as presentation layer to generate some plots based on R package. The charts are working good and now the users requires to download the data used to generate the plot for deeper analysis. There is possible to retrieve the data? It is possible to do not double call to those functions retrieving data (I am connected to DB)?

I want to put a button, then the final user can click and start downloading a file (plain text or any format) and correlate the information displayed in the chart with the data received.

Thanks a lot for your response.

役に立ちましたか?

解決

You probably want to create two functions in R:

  • getdata: a function that retrieves the data from your database, and returns the data frame.
  • makeplot : a function with a dataframe argument that creates your plot and returns nothing.

Then your client you can call them separately. First the client calls getdata to retrieve the data from the db, and the server will respond with a temporary {key} that represents the returned dataframe object on the server, for example x01234567.

Then you can use this key to either download the dataset or use it as an argument to create the plot. To download the data, simply create a hyperlink to for example:

  • http://your.server.com/ocpu/tmp/x01234567/R/.val/csv
  • http://your.server.com/ocpu/tmp/x01234567/R/.val/tab
  • http://your.server.com/ocpu/tmp/x01234567/R/.val/json

To create the plot, the client calls makeplot and passes x01234567 as the argument value for the data frame. The OpenCPU server will automatically lookup the object for this key to the dataframe object that was returned before by getdata.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top