In SQL Server 2016 and later, you can publish an R function to the database as a stored procedure. This makes it possible to run your R function on the SQL Server itself, which makes the power of that server available for R computations, and also eliminates the time required to move data to and from the server. It also makes your R function available as a resource to DBAs for use in SQL queries, even if they don't know the R language.
Neils Berglund recently posted a detailed tutorial on using the sqlrutils package to publish an R function as a stored procedure. There are several steps to the process, but ultimately it boils down to calling registerStoredProcedure on your R function (and providing the necessary credentials).
If you don't have a connection (or the credentials) to publish to the database yourself, Niels also explains how to use the StoredProcedure function to generate a SQL Server source file defining a stored procedure including your R function, which you can provide to a DBA to deploy.
You can find the complete tutorial, including detailed explanations of the various parameters, at the link below.
Niels Berglund: Creating R Stored Procedures in SQL Server 2016 Using sqlrutils
Can CRAN or GitHub packages be called from the stored procedures?
Posted by: tyler rinker | August 10, 2017 at 10:59
Yes, basically any code that you can run from your desktop can also be run in a proc.
Posted by: Hong Ooi | August 10, 2017 at 12:54
Thanks for the earlier response. Is it possible to install sqlrutils into a local R session? install.packages('sqlrutils') does not work (not a CRAN package obviously) and google-fu does not show how to install it locally.
Posted by: tyler rinker | August 10, 2017 at 19:01
It's part of Microsoft R Server.
https://docs.microsoft.com/en-us/r-server/
Posted by: Hong Ooi | August 10, 2017 at 20:11