20

Im new to R and H2O and I have tried to find a way to convert r data frame to a h2o object. I have spent some time research on how to do this with no luck. Other way around is possible and well documented as follows.

prosPath = system.file("extdata", "prostate.csv", package="h2o")
prostate.hex = h2o.importFile(localH2O, path = prosPath)
prostate.data.frame <- as.data.frame(prostate.hex)

But what i want is complete opposite of this. I wants to convert r "prostate.data.frame" data object converted to h2o object named "prostate.hex". Thanks in advance.

user4157124
  • 2,809
  • 13
  • 27
  • 42
plr
  • 511
  • 3
  • 5
  • 15

3 Answers3

35

As per h2o version 3.6.0.8, it does not require any parameters. Example:

iris.hex <- as.h2o(iris)
Ram
  • 351
  • 1
  • 3
  • 2
16

Please try this:

prostate.hex <- as.h2o(localH2O, prostate.data.frame, key="prostate.hex")
Dusan Grubjesic
  • 945
  • 2
  • 9
  • 16
  • 3
    This is now quite out of date (since h2o version 3). See also: [Unable to convert data frame to h2o object](http://stackoverflow.com/questions/31442820/unable-to-convert-data-frame-to-h2o-object) – smci Aug 10 '16 at 17:55
  • The answer by @Ram is the easier/simpler one. – xbsd Mar 02 '18 at 15:52
12

The accepted answer is out of date at this point (Jan-22-2016), so here's what works at present day

prostate.hex <- as.h2o(prostate.data.frame, destination_frame="prostate.hex")
Matthew Drury
  • 845
  • 8
  • 17