View source: R/intervalaverage_functions.R
CJ.dt | R Documentation |
similar to data.table::CJ and base::expand.grid except for rows of data.tables.
CJ.dt(..., groups = NULL)
... |
data.tables |
groups |
a character vector corresponding to column names of grouping vars in all of the data.tables |
CJ.dt computes successive cartesian join over rows of each table paying no attention to whatever the tables are keyed on.
#' 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]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.