【问题标题】:Specify parameter that contains a dot in its name using rpy2使用 rpy2 指定名称中包含点的参数
【发布时间】:2020-11-17 14:01:58
【问题描述】:

使用 Python,如何使用rpy2 实现以下 R 语句?

library(climatol)
homogen('Vel',2011,2012,tinc='6 hour',expl=TRUE,dz.max=10)

以下 Python 代码适用于除dz.max 之外的所有参数。

from rpy2.robjects import r
from rpy2.robjects.packages import importr
importr('climatol')

r['homogen']('Vel',2011,2012,tinc='6 hour',expl=r['as.logical']('T'))

我发现我可以使用r[<function_name>] 调用R 函数,而不管它们的名称中是否有一个点,例如as.logical,我曾经用它来调用布尔值True。现在如何指定名称包含点的参数,如dz.max 的情况?

感谢您的帮助。

【问题讨论】:

    标签: python r rpy2


    【解决方案1】:
    from rpy2.robjects import r
    from rpy2.robjects.packages import importr
    climatol = importr('climatol')
    climatol.homogen('Vel', 2011, 2012, tinc='6 hour', expl=True, dz_max=10)
    

    考虑查看文档,例如介绍:

    https://rpy2.github.io/doc/v3.3.x/html/introduction.html

    【讨论】:

      猜你喜欢
      • 2020-08-22
      • 1970-01-01
      • 2019-11-23
      • 2019-08-01
      • 1970-01-01
      • 2011-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多