Search code examples
pythonrsweaverpy2

how to configure Sweave it's work and recognize for Rpy2?


how to configure Sweave it's work and recognize for Rpy2?

I use this

 import rpy2.robjects as robjects

  R["library"]("utils")
  R["library"]("tools")
  R['sweave("/var/www/tmp/pywps/central.Rnw")']
  R['texi2dvi("/var/www/tmp/pywps/central.tex", pdf=TRUE)']

but I get these errors

[File "/usr/lib/python2.6/dist-packages/rpy2/robjects/__init__.py", line 241, in   __getitem__
    res = rinterface.globalenv.get(item)
    LookupError: 'Sweave("/var/www/tmp/pywps/central.Rnw")' not found
     Traceback (most recent call last):]

thanks for your answers and help


Solution

  • Use square brackets to get an R object, then call it from Python. Or use () brackets to pass a line to R:

    R["Sweave"]("/var/www/tmp/pywps/central.Rnw")
    R('Sweave("/var/www/tmp/pywps/central.Rnw")')
    

    Sweave needs a capital S (in my tests).