示例#1
0
 def __init__(self):
     assert embedded.isinitialized()
     robj = StrSexpVector(['R.version'])
     with memorymanagement.rmemory() as rmemory:
         parsed = _rinterface._parse(robj.__sexp__._cdata, 1, rmemory)
     res = baseenv['eval'](parsed)
     self._version = OrderedDict((k, v[0]) for k, v in zip(res.names, res))
示例#2
0
def parse(text: str, num: int = -1):
    """
    :param:`text` A string with R code to parse.
    :param:`num` The maximum number of lines to parse. If -1, no
      limit is applied.
    """
    if not isinstance(text, str):
        raise ValueError('text must be a string.')
    robj = StrSexpVector([text])
    return _rinterface._parse(robj.__sexp__._cdata, num)
示例#3
0
def parse(text: str, num: int = -1):
    """Parse a string as R code.

    :param:`text` A string with R code to parse.
    :param:`num` The maximum number of lines to parse. If -1, no
      limit is applied.
    """

    if not isinstance(text, str):
        raise TypeError('text must be a string.')
    robj = StrSexpVector([text])
    with memorymanagement.rmemory() as rmemory:
        res = _rinterface._parse(robj.__sexp__._cdata, num, rmemory)
    return res