我有以下两行代码在 R 和 Python 中都运行良好(通过 Rpy):
[R] rcut = cut(vector, brks)
[Python] rcut = r.cut(vector, brks)
但是,如果我想添加 include.lowest=TRUE 的参数,它会按预期在 R 中运行:
[R] rcut = cut(vector, brks, include.lowest=TRUE)
但它在 Rpy 中不起作用:
[Python] rcut = r.cut(vector, brks, include_lowest="TRUE")
出现以下错误:
rpy.RPy_RException: Error in ok && include.lowest : invalid 'y' type in 'x && y'
您知道是什么原因造成的吗?我应该怎么做才能让它发挥作用?谢谢!
请您参考如下方法:
我不知道 rpy,但会不会是因为使用了 "TRUE"(一个字符)而不是 TRUE(一个合乎逻辑)?
编辑:rpy 文档似乎表明使用 r.TRUE:
http://rpy.sourceforge.net/rpy/doc/rpy_html/R-boolean-objects.html#R-boolean-objects
