Converting an RPy2 ListVector to a Python dictionary

前端 未结 7 1212
日久生厌
日久生厌 2020-12-09 16:46

The natural Python equivalent to a named list in R is a dict, but RPy2 gives you a ListVector object.

import rpy2.robjects as robjects

a = robjects.r(\'list         


        
7条回答
  •  隐瞒了意图╮
    2020-12-09 17:49

    You can also do the following:

    In

    dict(a.items())
    

    Out

    {'foo': R object with classes: ('character',) mapped to:
     ['barbat'], 'fizz': R object with classes: ('numeric',) mapped to:
     [123.000000]}
    

提交回复
热议问题