You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not an issue but rather a query on how to use the new V8 version to call R functions from within Javascript
I have read the article and loved it and so would like to know how can the new feature be leveraged in my particular case cited below.
I have a shinyapp where I am using a JS charting library. I am computing the data in R and passing it to the Javascript using shinyjs. Shinyjs uses V8. This works great. Now as my data size increase or users from remote geographies try to access my app, I am having to transfer huge datasets from my server.ui to the client-side javascript library and network bandwidth is slowing my app down. I was wondering if I could transfer the entire computation to the client side by enabling the execution of the Rscript functions within JS. Then I can pass the computed data (which I think would now reside on the client-side) directly to the charting library and enable me to bypass the transfer of heavy data between server and the client. Let me know if I am making sense so far or I am conceptually inaccurate (which can well be the case given my limited knowledge in this field).
So, if the above theory makes sense, I would like to run the R functions from a particular package within JS.
Current Scenario:
When app loads, the R script pulls an initial data set and passes it to the JS charting library using shinyJS. This is when the initial transfer of data between server and client takes place and this cannot be avoided.
Say the initial data is a data frame DF. DFJson <- jsonlite::toJSON(DF)
Now pass this json to the JS charting library
For subsequent calculations based on users input, all I need to do is use the same json which I have passed onto the JS and run some R functions on it and then pass it back to the charting library. In the current scenario, I am computing the revised data within R and passing it back to JS
DF<-newDF(DF)
DFJson <- jsonlite::toJSON(DF)
newDF<-function(data){
#convert the data frame to xts
data<-as.xts(data)
SMA<-quantmod::SMA(data,20)
data<-merge(data,SMA)
#convert it back to data frame
data<-as.data.frame(Date=index(data),coredata(data))
return(data)
}
Now this new data with an additional column is being transferred to the JS library. This time again the transfer between server and client is subject to network bandwidth. I would like to bypass these subsequent transfers by computing the new data within JS using the R function newDF that I have defined. Please note that DF has dependency on the R library quantmod.
Do I make sense at all.
If yes, can I perform the above strategy using the new V8.
Do I need to place my function newDF within gloabl.R
Appreciate a small example of writing newDF within JS using v8 console.R API
Regards
SD
The text was updated successfully, but these errors were encountered:
Hi,
This is not an issue but rather a query on how to use the new V8 version to call R functions from within Javascript
I have read the article and loved it and so would like to know how can the new feature be leveraged in my particular case cited below.
I have a shinyapp where I am using a JS charting library. I am computing the data in R and passing it to the Javascript using shinyjs. Shinyjs uses V8. This works great. Now as my data size increase or users from remote geographies try to access my app, I am having to transfer huge datasets from my server.ui to the client-side javascript library and network bandwidth is slowing my app down. I was wondering if I could transfer the entire computation to the client side by enabling the execution of the Rscript functions within JS. Then I can pass the computed data (which I think would now reside on the client-side) directly to the charting library and enable me to bypass the transfer of heavy data between server and the client. Let me know if I am making sense so far or I am conceptually inaccurate (which can well be the case given my limited knowledge in this field).So, if the above theory makes sense, I would like to run the R functions from a particular package within JS.
Current Scenario:
Say the initial data is a data frame DF.
DFJson <- jsonlite::toJSON(DF)
Now pass this json to the JS charting library
Now this new data with an additional column is being transferred to the JS library. This time again the transfer between server and client is subject to network bandwidth. I would like to bypass these subsequent transfers by computing the new data within JS using the R function newDF that I have defined. Please note that DF has dependency on the R library quantmod.
Regards
SD
The text was updated successfully, but these errors were encountered: