crbind: Combine data sources by rows or columns

Description Usage Arguments Details See Also Examples

Description

Combine data sources by rows or columns

Usage

1
2
3
4
5
6
7
## S3 method for class 'RxXdfData'
cbind(..., deparse.level = 1,
  .outFile = tbl_xdf(lst[[1]]), .rxArgs)

## S3 method for class 'RxXdfData'
rbind(..., deparse.level = 1,
  .outFile = tbl_xdf(lst[[1]]), .rxArgs)

Arguments

...

Objects to combine. Can be RxXdfData or tbl_xdf data sources.

deparse.level

For compatibility with the base cbind and rbind generics. Not used.

.outFile

Output format for the returned data. If not supplied, create an xdf tbl; if NULL, return a data frame; if a character string naming a file, save an Xdf file at that location.

.rxArgs

A list of RevoScaleR arguments. See rxArgs for details.

Details

Due to the specifics of how R searches for methods for cbind and rbind, there are a few caveats to using these. First, all the objects to be combined must be Xdf files for the correct method to be found; in particular, trying to combine a data frame and an Xdf file will result in an error (or bad output). Second, specifying the rxArgs argument will fail if called from the generic. These issues can be worked around by calling the Xdf method directly: cbind.RxXdfData(xdf1, xdf2, .rxArgs=...), or rbind.RxXdfData(xdf1, xdf2, .rxArgs=...).

These methods also have some limitations compared to cbind and rbind for data frames. The cbind.RxXdfData method will drop columns that have duplicate names, with a warning; this behaviour is different to cbind with data frames, which will create an output df with duplicated names; and to dplyr::bind_cols, which will rename columns to be unique. The rbind.RxXdfData method will give an error if the columns in all the objects don't match, rather than creating new columns.

These methods support HDFS data in the local compute compute context, but not the Hadoop or Spark compute contexts.

See Also

cbind and rbind in base R, bind_cols and bind_rows in package dplyr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# cbind two Xdf files together
mtx <- as_xdf(mtcars, overwrite=TRUE)
tbl <- transmute(mtx, mpg2 = 2 * mpg)
cbind(mtx, tbl)

# rbind two Xdf files together
mtx2 <- as_xdf(mtcars, overwrite=TRUE)
rbind(mtx, mtx2)

# combine an Xdf file and a data frame: must explicitly call RxXdfData method
rbind.RxXdfData(mtx, mtcars)

# save to a persistent Xdf file: again, must explicitly call RxXdfData method
cbind.RxXdfData(mtx, tbl, .outFile="mtcars_cbind.xdf")

RevolutionAnalytics/dplyrXdf documentation built on June 3, 2019, 9:08 p.m.