Accessing functions with a dot in their name (eg. “as.vector”) using rpy2

后端 未结 2 383
无人及你
无人及你 2020-12-21 08:15

I am trying to access the \"as.vector\" R function from within Python, using rpy2. Let\'s say, for the sake of simplicity, that I want to do something as simple as this usin

相关标签:
2条回答
  • 2020-12-21 08:53

    Get a reference to the function using the rpy2.robjects.r interface.

    So, you could do something like:

    as_vector = robjects.r("as.vector")
    vect = as_vector(r_vect)
    
    0 讨论(0)
  • 2020-12-21 08:56

    According to the documentation, rpy2 does not replace dots by underscores when using 'rpy2.robjects.r'.

    You may want to consider the use of 'importr()'

    0 讨论(0)
提交回复
热议问题