CJ.dt {intervalaverage} | R Documentation |
grid expand an arbitrary number of data.tables
Description
similar to data.table::CJ and base::expand.grid except for rows of data.tables.
Usage
CJ.dt(..., groups = NULL)
Arguments
... |
data.tables |
groups |
a character vector corresponding to column names of grouping vars in all of the data.tables |
Details
CJ.dt computes successive cartesian join over rows of each table paying no attention to whatever the tables are keyed on.
Examples
#' CJ.dt(data.table(c(1,2,2),c(1,1,1)),data.table(c("a","b"),c("c","d")))
#If you want to expand x to unique values of a non-unique columns in y
x <- data.table(c(1,2,3),c("a","b","b"))
y <- data.table(id=c(1,2,2,1,3),value=c(2,4,1,7,3))
z <- CJ.dt(x, y[,list(id=unique(id))])
#if you want to merge this back to y
y[z,on="id",allow.cartesian=TRUE] #or z[y,on="id",allow.cartesian=TRUE]
[Package intervalaverage version 0.8.0 Index]