microsoft/SQL-Server-R-Services-Samples

plyr and zoo packages must be installed or the PM doesnt work

yorek opened this issue · 6 comments

yorek commented

If the "plyr" and the "zoo" packages are not installed the PredictiveMaintenance sample fail giving a weird error message:

ERROR: The sample data set for the analysis has no variables.
Error in doTryCatch(return(expr), name, parentenv, handler) : 
  ERROR: The sample data set for the analysis has no variables.

Yes, the "plyr" and "zoo" packages are required for the PredictiveMaintenance sample. The original error message will be written to SQL server error log, and won't surface to the end user. This error won't block the R script, so it will continue. Finally it will fail since the dataset extracted using "plyr" or "zoo" functions are empty, which will halt the execution of the R script and finally you get the error message as your posted.
Hopefully this explained your question of getting "weird" error message.

Thanks,
Zhixing

yorek commented

Thanks for the explanation. Wouldn't it be great if help can state the requirements of "plyr" and "zoo" more clearly? If you don't mind I'll go on to fix this and create a pull request,

I will add library("zoo") and library("plyr") in the beginning of the R script. So if the packages could not loaded, it will surface the correct error message to end user.

Thanks,
Zhixing

For the retail processing sample the package plyr is also required, I was able to install the package manually, but now I get a missing dependency for the rccp package.

Create SQL stored procedure for data preprocessing...
Execute data preprocessing...

Invoke-Sqlcmd : A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
An external script error occurred:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called 'Rcpp'
Error: package or namespace load failed for 'plyr'
Error in ScaleR. Check the output for more information.

When I try to install the Rccp package I get the error:

Warning message:
package ‘Rccp’ is not available (for R version 3.2.2)

Main question I have is are you currently able to run the sample PowerShell script with the current version of R Services, I am assuming it is my setup.

R version 3.2.2

Details:
I was able to install Rccp eventually with the following

lib.SQL <- "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\R_SERVICES\library"
install.packages("C:\Rcpp_0.12.7.zip", lib = lib.SQL,dependencies=T,repos=NULL)

but still had another error when running powershell:

Create SQL stored procedure for data preprocessing...
Execute data preprocessing...

Invoke-Sqlcmd : A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
An external script error occurred:
Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite
Calls: source -> withVisible -> eval -> eval -> seq -> seq.POSIXt
In addition: Warning messages:
1: In min.default(numeric(0), na.rm = FALSE) :
no non-missing arguments to min; returning Inf
2: In max.default(numeric(0), na.rm = FALSE) :
no non-missing arguments to max; returning -Inf
Error in ScaleR. Check the output for more information.
Error in eval(expr, envir, enclos) :
Error in ScaleR. Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted
At C:\Databases\DB SCRIPTS\Projects\SQL Server Samples - Github\SQL-Server-R-Services-Samples\RetailForecasting\SQLR\SQLR-Retail-Forecasting.ps1:58 char:5

  • Invoke-Sqlcmd -ServerInstance $ServerName  -Database $DBName -Use ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException
    • FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

Other random info:

sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.437
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] RevoUtilsMath_8.0.3 RevoUtils_8.0.3 RevoMods_8.0.3 RevoScaleR_8.0.3 lattice_0.20-33
[6] rpart_4.1-10

loaded via a namespace (and not attached):
[1] codetools_0.2-14 rtvs_1.0.0.0 grid_3.2.2 iterators_1.0.8 foreach_1.4.3

Eventually I fixed my issues, really for someone who is new like me to R it would be good to have the packages installed but once I figured that out is went pretty smooth

I had a few beginner setup issues, maybe this will help, and of course I am a rookie so I am open to suggestions to make the process cleaner:

  1. Had multiple libraries, the default installed as part of R Studio and then the Microsoft R Services library, so I needed to install to the correct library.

#setup specific library path
lib.SQL <- "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\R_SERVICES\library"
#install package from binary zip file with dependencies, had to install from Revolutionary Analytics to get rid of "package ‘Rccp’ is not available (for R version 3.2.2)" error
install.packages("C:\Rcpp_0.12.7.zip", lib = lib.SQL,dependencies=T,repos=NULL)

  1. Incompatibilities between the rJava package and the 32 bit version of Java installed on my machine, installing the 64 bit version of Java on my 64 bit version of Windows 10 resolved the issue.
  2. To be safe, when working with Microsoft R services I started downloading the required packages from Revolutionary Analytics instead of Cran, I believe this resolved the errors with the Rccp package as noted above, "package ‘Rccp’ is not available (for R version 3.2.2)".
  3. Just installing the required libraries, which is pretty simple but needs to be done in a specific way.
    See: https://msdn.microsoft.com/en-us/library/mt591989.aspx