Find installed R packages on your Microsoft R Server

Want to find out what R libraries you have available in your SQL Server 2016 environment?

2016-06-16 10_28_29-microsoft r server - Google Search

Run the following scripts to find out how many R Libraries you have available for your R Server in SSMS:

EXECUTE sp_execute_external_script
          @language = N'R'
         ,@script = N'installpackages <- nrow(installed.packages());
                    OutputDataSet <- as.data.frame(installpackages);'
         ,@input_data_1 = N'SELECT 1 AS NOF_LIBRARIES'
 WITH RESULT SETS(
                  (NOF_Libraries int)
                  );
GO

And all their names along with couple of additional information (version, dependency,…)

EXECUTE sp_execute_external_script
  @language=N'R'
 ,@script = N'installpackages <-installed.packages();
             PackageName <- installpackages[,1];
             PackageVersion <- installpackages[,3];
             PackagePath <- installpackages[,2];
             PackageDepend <- installpackages[,6];
             OutputDataSet <- as.data.frame(cbind(PackageName,PackageVersion,PackageDepend,PackagePath));'
,@input_data_1 = N'SELECT 1 as col'
WITH RESULT SETS (
                   (PackageName NVARCHAR(50)
                   ,PackageVersion NVARCHAR(50)
                   ,PackageDepend NVARCHAR(250)
                   ,PackageDepend NVARCHAR(500))
                  );
GO

Happy R-SQLing 😉

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s