开发者

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

how to configure Sweave it's work and recognize for开发者_JS百科 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


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).


Uh, does this work? You're not doing all the R[] invocations the same way.

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")

(I've never used Rpy2 so this is totally guessing.)


Using the R package importer would let you use autocompletion in your IDE or interactive shell and make the code more Python-like.

from rpy2.robjects.packages import importr
utils = importr('utils')
utils.Sweave("/var/www/tmp/pywps/central.Rnw")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜