Calling R Script from python in AWS lambda

前端 未结 1 619
旧时难觅i
旧时难觅i 2020-12-10 22:56

I know there is a package called rpy2 in python in order to integrate R and python.

Calling R script from python using rpy2, in this link they have de

相关标签:
1条回答
  • 2020-12-11 00:01

    I am using very simple methode for interachanging between python and R by using rpy2, here is one example where I write R script as string and then use rpy2 to translate it for R and return it back,

       path="H:/projects/somepackage/CODE"
       from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage
       string = """
       setwd <- function(x) {
       setwd("%s")
       return (getwd())}
       """ % (path)
       print (string)
       powerpack = SignatureTranslatedAnonymousPackage(string, "powerpack")
       #The R functions setwd can be  called with powerpack.setwd () as
       powerpack.setwd()[0]
    

    I am not sure if it might be useful in your case but if you somehow manage to transfer your code to AWS you will definitely get the results... You can also try to save the string as a file, then ask Python to compile it as external function(I used to do so in the past without rpy2)

    Cheers

    0 讨论(0)
提交回复
热议问题