Skip to content

Commit

Permalink
unlist a list of H2OParsedData objects in cbind
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Oct 27, 2014
1 parent 9ceae75 commit c9052c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/h2o-package/R/Classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ setMethod("[[<-", "H2OParsedData", function(x, i, value) {
cbind.H2OParsedData <- function(..., deparse.level = 1) {
if(deparse.level != 1) stop("Unimplemented")

l <- list(...)
l <- unlist(list(...))
# l_dep <- sapply(substitute(placeholderFunction(...))[-1], deparse)
if(length(l) == 0) stop('cbind requires an H2O parsed dataset')

Expand Down
5 changes: 5 additions & 0 deletions R/h2o-package/R/ParseImport.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ h2o.interaction <- function(data, key=NULL, factors, max_factors, min_occurrence
if(missing(max_factors)) stop("max_factors must be specified")
if(missing(min_occurrence)) stop("min_occurrence must be specified")

if (is.list(factors)) {
res <- lapply(factors, function(factor) h2o.interaction(data, key, factor, max_factors, min_occurrence))
return(cbind.H2OParsedData(res))
}

if(!is.numeric(factors)) stop("factors must be a numeric value")
if(max_factors < 1) stop("max_factors cannot be < 1")
if(!is.numeric(max_factors)) stop("max_factors must be a numeric value")
Expand Down
4 changes: 0 additions & 4 deletions R/tests/testdir_munging/slice/runit_cbind.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ test.cbind <- function(conn) {
hdf_filt <- cbind(hdf[,3] <= 5, hdf[,4] >= 4)
expect_that(dim(hdf_filt), equals(c(12, 2)))

# cbind sets column names correctly
hdf_names <- cbind(colX = xx, colY = yy)
expect_that(colnames(hdf_names), equals(c("colX", "colY")))

# cbind unequal rows fails
expect_that(cbind(hdf, otherhdf), throws_error())

Expand Down

0 comments on commit c9052c0

Please sign in to comment.