Installing R packages in SQL Server R Services

  • tomaz.kastrun

    SSCrazy

    Points: 2085

    Comments posted to this topic are about the item Installing R packages in SQL Server R Services

    Tomaž Kaštrun | twitter: @tomaz_tsql | blog:  https://tomaztsql.wordpress.com/

  • INCREDIBLEmouse

    SSC Eights!

    Points: 814

    I'm quite surprised the lack of the ability for the analyst/data scientist to install a package and that it not only be installed locally, but also doubly installed in the server path. This should not require a call to an administrator or IT department. Why is that not built into the new VS R IDE? :blink:

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    This is a whole new area for me. Thanks for the lesson.

  • tomaz.kastrun

    SSCrazy

    Points: 2085

    Hi,

    you can install package in RTVS (VS R IDE).

    IMHO IDE should be prepared for e.g.: client machine with all packages pre-installed (compatible with version), so data wrangled, data analyst should not worry about this.

    Best, Tomaž

    Tomaž Kaštrun | twitter: @tomaz_tsql | blog:  https://tomaztsql.wordpress.com/

  • tomaz.kastrun

    SSCrazy

    Points: 2085

    Iwas Bornready (9/29/2016)


    This is a whole new area for me. Thanks for the lesson.

    Great to hear. Hope you enjoyed it.

    Best, Tomaž

    Tomaž Kaštrun | twitter: @tomaz_tsql | blog:  https://tomaztsql.wordpress.com/

  • INCREDIBLEmouse

    SSC Eights!

    Points: 814

    tomaz.kastrun (9/30/2016)


    Hi,

    you can install package in RTVS (VS R IDE).

    IMHO IDE should be prepared for e.g.: client machine with all packages pre-installed (compatible with version), so data wrangled, data analyst should not worry about this.

    Best, Tomaž

    Agreed. That's not the question at hand, or an issue. Having the packages installed on the server as well as the local machine is the problem.

    Thoughts?

  • tomaz.kastrun

    SSCrazy

    Points: 2085

    INCREDIBLEmouse (9/30/2016)


    tomaz.kastrun (9/30/2016)


    Hi,

    you can install package in RTVS (VS R IDE).

    IMHO IDE should be prepared for e.g.: client machine with all packages pre-installed (compatible with version), so data wrangled, data analyst should not worry about this.

    Best, Tomaž

    Agreed. That's not the question at hand, or an issue. Having the packages installed on the server as well as the local machine is the problem.

    Thoughts?

    Having all the packages aligned with the server version, as well as the R engine would be the easiest way to handle packages on client/local/server/remote machine. In addition,

    function RxComputeContext (https://msdn.microsoft.com/en-us/library/mt732690.aspx) gives you ability to push the computation to server/remote machine for better and faster performance. Given this, also job of code validation would be simplified.

    In enterprise environment this task should be performed by a administrator.

    Best, Tomaž

    Tomaž Kaštrun | twitter: @tomaz_tsql | blog:  https://tomaztsql.wordpress.com/

  • INCREDIBLEmouse

    SSC Eights!

    Points: 814

    😀

    Philosophically, I disagree and would approach it conversely, but I do now understand what you're saying, and the reasoning behind it. Seems like that method will eventually stifle progress. 🙂

  • tomaz.kastrun

    SSCrazy

    Points: 2085

    🙂 And what is your point of view on this topic, regardless of different point of views (or not).

    best

    Tomaž Kaštrun | twitter: @tomaz_tsql | blog:  https://tomaztsql.wordpress.com/

  • jroycma

    SSC Rookie

    Points: 37

    Hello Tomaz,

    I want to thank you for all the wonder posts you write to help us all and particularly myself. I have benefited immensely.

    I followed you advice with copying and pasting R packages from my R client to my R Services library as described in your post.
    However, after copying the R package folder (e.g. ROCR) from my Rclient into R Services library, I obtain an odd result.

    The results are as following:

    1) R library shows the folder being populated correctly.

    2) To verify the result, I ran a script such as  ... (sp_execute_external_script @language = N'R', @script = N'OutputDataSet <- data.frame(installed.packages())')  ...  and the package shows up in the list of packages in the Results tab.

    3) However when I run the following .....
    execute sp_execute_external_script
    @language=N'R',
    @script=N'library(ROCR); OutputDataSet<-InputDataSet',
    @input_data_1=N'select 1'
    WITH RESULT SETS undefined;
    GO

    I get the following error ......  

    Msg 39004, Level 16, State 20, Line 8
    A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
    Msg 39019, Level 16, State 2, Line 8
    An external script error occurred:
    Error in library(ROCR) : there is no package called 'ROCR'
    Calls: source -> withVisible -> eval -> eval -> library

    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

    OR: (in a second SQL instance)

    Msg 39004, Level 16, State 20, Line 1
    A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
    Msg 39019, Level 16, State 1, Line 1
    An external script error occurred:
    Loading required package: gplots
    Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
    there is no package called 'gtools'
    In addition: Warning messages:
    1: package 'ROCR' was built under R version 3.4.1
    2: package 'gplots' was built under R version 3.3.3
    Error: package 'gplots' could not be loaded

    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

    I have tried this on two different SQL instances just to be sure I would get a repeatable issue.What would cause either of these errors and how can I fix this? 

    I appreciate the help in advance.

    Best wishes,

    Jay

  • tomaz.kastrun

    SSCrazy

    Points: 2085

    Hi Jay,

    sorry for late response.

    This looks to me that ROCR is not available at the right location from where you are calling this R script. So make sure that you install (or copy/paste) ROCR package at the location of your R SQL Services.
    How to find the right path of your R Services packages, is simply by checking installed.packages parameters: sp_execute_external_script @language = N'R', @script = N'OutputDataSet <- data.frame(installed.packages())' of the path and see if there is your ROCR package.
    It can also be the case that ROCR is not compatible with your R code or that you have some dependent packages missing.

    Let me know if this has somehow helped you, if not I would love to take a look into your problem/computer thouroguhly.

    Best, Tomaž

    Tomaž Kaštrun | twitter: @tomaz_tsql | blog:  https://tomaztsql.wordpress.com/

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply