I am trying to create a unique combination of all elements from two vectors of different size in R.
For example, the first vector is
a <- c(\"ABC\
Missing in this r-faq overview is the CJ-function from the data.table-package. Using:
library(data.table)
CJ(a, b, unique = TRUE)
gives:
a b 1: ABC 2012-05-01 2: ABC 2012-05-02 3: ABC 2012-05-03 4: ABC 2012-05-04 5: ABC 2012-05-05 6: DEF 2012-05-01 7: DEF 2012-05-02 8: DEF 2012-05-03 9: DEF 2012-05-04 10: DEF 2012-05-05 11: GHI 2012-05-01 12: GHI 2012-05-02 13: GHI 2012-05-03 14: GHI 2012-05-04 15: GHI 2012-05-05
NOTE: since version 1.12.2 CJ autonames the resulting columns (see also here and here).