R applications with ReactJS

your R code logic to process data train data create data model predict data …generate data_output list('response' = data_output)}Consume R API using ReactJS :Now your web api is ready using R..The api will responses the resultant data in JSON format..So we have to consume this API and display it with React.In react, you can use fetch, jQuery ajax or whatever request mechanism you prefer to actually perform the collection of your data..You can add your fetch code in react componentDidMount() function and update your state with the response data.componentDidMount () { fetch(`http://localhost:8000/createmodel`) .then(result => { return result.json()}) .then(data=> { this.setState({ data:data.response }); });}For plotting the output in graphs you can use libraries like D3, ReactD3 or React charts etc.Advantages of this process :R will deals with only data management , model creation and prediction and hence reduce the load in R-server by elimination of UI and output graph plotting.For front-end UI ReactJS is much better in terms of performance and code simplicity.As R output is exposed as a web API, front-end can be switched to any technologies like angular, vue.js etc … without distracting the R code… More details

Leave a Reply