【发布时间】:2019-09-02 08:26:01
【问题描述】:
在 R 中,NULL 值通常用作默认值。使用 Python 和 RPy2,如何显式提供 NULL 参数?
None 不可转换 (NotImplementedError),字符串 'NULL' 只会被转换为字符串并在执行过程中导致错误。
以tsintermittent 包为例:
import numpy as np
from rpy2.robjects.packages import importr
from rpy2.robjects import numpy2ri
numpy2ri.activate()
tsintermittent = importr('tsintermittent')
crost = tsintermittent.crost
ts = np.random.randint(0,2,50) * np.random.randint(1,10,50)
# implicit ok, default w is NULL
# crost(ts)
# explicit - how to do it?
# RRunTimeError - non numeric argument
crost(ts, w='NULL')
# NotImplementedError
crost(ts, w=None)
【问题讨论】:
标签: r python-3.x null rpy2