4

I am trying to call the R function memory.limit, with the argument 'size', using rpy2. I followed the instructions given here: Accessing functions with a dot in their name (eg. "as.vector") using rpy2, but cannot get it to work.

This is what I have tried:

from rpy2.robjects.packages import importr
from rpy2 import robjects

utils = importr('utils')
memory_limit = robjects.r("memory.limit")
utils.memory_limit(size=50000)

and also

from rpy2 import robjects

memory_limit = robjects.r("memory.limit")
memory_limit(size=50000)

In both cases I get the following error:

RRuntimeError: Error in (function (size = NA)  : incorrect argument

Can you tell me what I am doing wrong?

panda
  • 821
  • 1
  • 9
  • 20

1 Answers1

0

I guess by now you have solved this, but I would do like this:

import rpy2.robjects as robjects
memory_limit = robjects.r('utils::memory.limit')
memory_limit(size=50000)
fabiob
  • 273
  • 4
  • 14