H2O (0xData) 数据帧返回 R data.frame

H2O (0xData) data frame back to R data.frame

如果我使用 Jetty HashLoginService(即 -hash_login -login_conf realm.properties)启动 H2O 以使用密码保护我的 H2O 实例,我无法将 H2O 对象转换为 R 对象。

例如下面的 as.data.frame 将不起作用,如果我不使用 HashLoginService 就好像会起作用:

> require(h2o)
> h2o.init(port     = 54324,  startH2O = F, 
           password = "pass", username = "uname")
 Connection successful!

R is connected to the H2O cluster: 
    H2O cluster uptime:         5 days 15 hours 
    H2O cluster version:        3.9.1.3405 
    H2O cluster name:           uname 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   22.19 GB 
    H2O cluster total cores:    8 
    H2O cluster allowed cores:  2 
    H2O cluster healthy:        TRUE 
    H2O Connection ip:          localhost 
    H2O Connection port:        54324 
    H2O Connection proxy:       NA 
    R Version:                  R version 3.1.1 (2014-07-10)

> packageVersion("h2o")
[1] ‘3.9.1.3405’

> df  <- data.frame(a = c(0.2, 0.3, 0.1, 0.5, 0.1, 0.2),
                    b = c(0.1, 0.1, 0.7, 0.3, 0.2, 0.9))

> h2o_df <- as.h2o(df, "h2o_df")
  |==============================================================================| 100%

> head(h2o_df)
     a    b
1  0.2  0.1
2  0.3  0.1
3  0.1  0.7
4  0.5  0.3
5  0.1  0.2
6  0.2  0.9

> class(h2o_df)
[1] "H2OFrame"

> as.data.frame(h2o_df)
                                                                X.html.
1                                                                <head>
2  <meta http-equiv=Content-Type content=text/html;charset=ISO-8859-1/>
3                                 <title>Error 401 Unauthorized</title>
4                                                               </head>
5                                                                <body>
6                                              <h2>HTTP ERROR: 401</h2>
7                      <p>Problem accessing /3/DownloadDataset. Reason:
8                                       <pre>    Unauthorized</pre></p>
9                       <hr /><i><small>Powered by Jetty://</small></i>
10                                                                     
11                                                                     
12                                                                     
13                                                                     
14                                                                     
15                                                                     
16                                                                     
17                                                                     
18                                                                     
19                                                                     
20                                                                     
21                                                                     
22                                                                     
23                                                                     
24                                                                     
25                                                                     
26                                                                     
27                                                                     
28                                                                     
29                                                                     
30                                                              </body>
31                                                              </html>
Warning message:
In read.table(file = file, header = header, sep = sep, quote = quote,  :
  cols = 1 != length(data) = 11

知道如何解决这个问题吗?


更新

这是一个错误,您可以在此处进行跟踪:https://0xdata.atlassian.net/browse/PUBDEV-2968

到目前为止似乎是一个错误。

as.data.frame.H2OFrame 中调用函数 getURL(来自 RCurl 包)以从 H2O 服务器检索数据。

无需传递任何凭据即可使用此功能。

一种解决方法是更改​​此函数并将 getURL(url) 替换为

ttt <- getURL(url, userpwd=paste0(conn@username,':',conn@password), httpauth = 1L)

或者检查是否给定用户名使用后者,否则使用前者。

已给出如何使用它的完整示例 here