【发布时间】:2017-12-21 14:36:43
【问题描述】:
我将 H2O 与 R 结合使用。当我尝试比较 H2O 框架的两个不同元素时,我得到一个环境变量 [1 行 x 1 列]。我想将此对象的类型转换为数值或布尔类型。
可重现的例子。
library(h2o)
h2o.init()
>d <- as.data.frame(c(1,2,3,4,5,1))
>d.hex <- as.h2o(d)
>d.hex[1]
c(1, 2, 3, 4, 5, 1)
1 1
[1 row x 1 column]
>typeof(d.hex[1])
[1] "environment"
我想要一种方法来转换以下代码,使其返回布尔值,或者 0 或 1。
>d.hex[1] == d.hex[6]
c(1, 2, 3, 4, 5, 1)
1 1
[1 row x 1 column]
预期输出
[1] True
或
[1] 1
【问题讨论】:
标签: r types boolean h2o comparison-operators