none
Is it possible to pre-load certain R packages for Webservices REST API RRS feed

  • Question

  • Hi ,

    suppose i have some large R packages and created a function

    foo <- function(x){
      # do some expensive calculation using large packages
      # these packages takes a while to load into memory
      x1 <- func1(x) # func1 is from library(SomeBigPkg)
      x2 <- func2(x1)
      x2 + x1
    }

    One practical example is that in the package SomeBigPkg, we initialize a database connection and kept it alive.

    is it possible for R Server to "pre-load" them into memory so that every function call will skip the initialization part & directly call foo? or i have to do the following:

    foo <- function(x){
      # do some expensive calculation using large packages
      # these packages takes a while to load into memory
    
      ## do i have to?
      library(SomeBigPkg)
    
      x1 <- func1(x) # func1 is from library(SomeBigPkg)
      x2 <- func2(x1)
      x2 + x1
    }

    Sorry i'm new to MSRS so may have asked some basic questions.

    thank you.

    Best,

    Ricky

    Thursday, March 9, 2017 3:13 PM

All replies