Thursday, February 3, 2011

Cartesian product (cross product) of Character Vectors - interaction()

> y <- c("1","2","3") > x <- c("aaa","bbb","ccc") > interaction(x,y)
[1] aaa.1 bbb.2 ccc.3
Levels: aaa.1 bbb.1 ccc.1 aaa.2 bbb.2 ccc.2 aaa.3 bbb.3 ccc.3

https://stat.ethz.ch/pipermail/r-help/2008-December/181756.html

No comments: