What are the constraints of FUN in H2O's apply function?

Viewed 254

I am using version 3.10.4.8.

library(h2o)
h2o.init(nthreads = -1)

df <- as.h2o(data.frame(x = 1:5, y = 11:15))

I'm trying to understand how to use the apply() function in H2O.

The following works as expected:

h2o::apply(df, 2, mean)
h2o::apply(df, 2, sum)
h2o::apply(df, 2, function(x) {2*x + 1})

But this does not:

h2o::apply(df, 2, sd)

The error returned is:

[1] "Lookup failed to find is.H2OFrame" Error in .process.stmnt(stmnt, formalz, envs) : Don't know what to do with statement: is.H2OFrame x

I also thought that H2O is actually using its own functions to do the computation, so the following should work:

h2o::apply(df, 2, h2o.mean)
h2o::apply(df, 2, h2o.sum)
h2o::apply(df, 2, h2o.sd) 

But it does not. The first two lines give the following error:

[1] "Lookup failed to find .newExpr" Error in .process.stmnt(stmnt, formalz, envs) : Don't know what to do with statement: .newExpr sd x na.rm

While the third line gives the following error:

[1] "Lookup failed to find .newExpr" Error in .process.stmnt(stmnt, formalz, envs) : Don't know what to do with statement: .newExpr sd x na.rm

What's going on and what are the things I should be aware of when passing stuff into FUN parameter in the apply() function? The documentation simply describes FUN as "the function to be applied".

0 Answers
Related