R/ifelse.R

## ----------------------------------------------------------------------
## ifelse
## ----------------------------------------------------------------------

setGeneric("ifelse")

setMethod("ifelse",
    signature(test = "db.obj"),
    function (test, yes, no)
    {
        test <- test[,]
        if (length(names(test)) != 1)
            stop(deparse(substitute(test)), " must have only one column",
                 " and the column type can be casted into boolean!")
        x <- test
        x$res <- no
        x$res[as.logical(test),] <- yes
        x$res
    }
)
greenplum-db/GreenplumR documentation built on Sept. 2, 2023, 8:09 a.m.