1

我有以下两行代码,它们在 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'

你知道是什么原因造成的,我应该怎么做才能让它发挥作用?谢谢!

4

2 回答 2

5

我不知道rpy,但这可能是由于使用"TRUE"(字符)而不是TRUE(逻辑)吗?

编辑:rpy文档似乎表明使用r.TRUE

http://rpy.sourceforge.net/rpy/doc/rpy_html/R-boolean-objects.html#R-boolean-objects

于 2010-08-19T20:01:01.487 回答
1

我对 Rpy 一无所知,但我想它必须是include_lowest=True(没有引号,True是 python 中的布尔值。)

于 2010-08-19T20:01:10.277 回答