You'll notice that I've also got another environment variable (application setting) defining where the R scripts are being kept. It's worth highlighting at this point that ensuring the use of application settings will help when you deploy to Azure as the R executables will typically be at a location such as "D:\home\R-3.3.3\bin\x64", you may not have that location available locally so using settings will make the code more portable and maintainable. Once that has been configured then we can simply call the R code using the methods provided by r-script and capturing the output. Make sure you have a read of the r-script documentation to see how to pass data in and get it back out.
We can then do any post-processing we need to with the output object and send it on it's way to the output location. In the case of an HTTP trigger this would be returning it back to the caller.