0

I am trying to read data through python in my web app and then analyze it in R. For this I am using pyper to perform the analysis. While creating a function, I get the output only if I write a single statement in function definition. But if I write more than one statement, neither do I get any error nor does my code run. i.e

>>>from pyper import *  
   r('replace<-function(stmt){stmt<-gsub("@(.*?) +","||T|| ",stmt)}')

works well enough but

>>>r('replace<-function(stmt)  
    {stmt<-gsub("@(.*?) +","||T|| ",stmt)  
     stmt<-gsub("(http://t.co/)[0-9a-zA-Z]*","||U|| ",stmt)}')

does not execute. This is the same case with all other functions. I am not able to club all commands within a single block. Please suggest a solution

ali_m
  • 71,714
  • 23
  • 223
  • 298

1 Answers1

0

May be you should call like this:

R("""replace<-function(stmt)  
    {stmt<-gsub("@(.*?) +","||T|| ",stmt)  
     stmt<-gsub("(http://t.co/)[0-9a-zA-Z]*","||U|| ",stmt)}""")
psl
  • 906
  • 6
  • 6