I need to do a cartesian product of two data frames. For example,
A = id weight type
10 20 a
10 30 b
25 10 c
B = date report
2007 y
2008 n
then C would be like after doing 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
as some ids are the same in A, so I cannot use a way like
C <- merge(A$id,B$date)
C <- merge(C,A,by="id")
C <- merge(C,B,by="date")
This way will generate more rows. Could anyone help me out of here? Thanks