I need to make the Cartesian product of two data frames. For instance,
A = id weight type
10 20 a
10 30 b
25 10 c
B = date report
2007 y
2008 n
then C would be put after the Cartesian product of A and B
C = id weight type date report
10 20 a 2007 y
10 20 a 2008 n
10 30 b 2007 y
10 30 b 2008 n
25 10 c 2007 y
25 10 c 2008 n
since some identifiers are the same in A, so I cannot use a method like
C <- merge(A$id,B$date)
C <- merge(C,A,by="id")
C <- merge(C,B,by="date")
This method will generate more lines. Can someone help me get out of here? Thanks
source
share