This is how you get R Integration in SQL Server 2016 (CTP3):
- Create a SQL 2016 CTP3 VM in Azure
- Run SQL 2016 Setup and install “Advanced Analytics Extensions” Feature
- Download and install: https://www.microsoft.com/en-us/download/details.aspx?id=49525
- Download and install: https://www.microsoft.com/en-us/download/details.aspx?id=49505 (only the 81.3 MB file)
- Run sp_configure 'external scripts enabled',1 in a SQL Query window to allow SQL Server the execution of external scripts.
- Download the SQLServer2016CTP3 Samples: https://www.microsoft.com/en-us/download/details.aspx?id=49502
There are some samples showing how to execute R Scripts in SQL Server. However they will not work unless you install the R-Packages you use in these scripts.
- To install the required R Packages you can use RStudio: https://www.rstudio.com/products/rstudio/download/
Hint: You might get this error when you install a package:
install.packages("ggplot2")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘ggplot2’
The solution is to change the mirror:
chooseCRANmirror(81)try again:
install.packages('ggplot2', repos='http://cran.us.r-project.org')
- Finally you can execute the sample scripts. (Everytime a library is missing, install it in RStudio as described)
- After you ran the sample files for iris data (highlighted in the first screenshot) you can configure SQL Server 2016 Reporting Services and in the Report Builder open the Sample Reports:
You will also find an example for a prediction model that can be deployed to SQL Server 2016 and can be called using T-SQL Code.
There is one example showing a regression model:
And a second example showing a classification model:
Conclusion: R-Integration is a brilliant new feature in SQL Server 2016. It enables the use of more than 7000 R-Packages with prediction models, optimization models and rich visualizations. In addition to that Revolution R Packages allow full parallelism and scalability (A big issue with traditional standalone R).
We can be sure to see more of this in the future.