I have data in a dataframe in the following format:
id a b c d e f x y z
1 0 0 0 1 1 0 1 0 1
2 1 0 0 1 0 0 1 0 0
What I would like to do is find out how many times a and x have a 1 in the same place, a and y have a 1 in the same row and so on. Essentially, (a,b,c,d,e,f) and (x,y,z) ought to be grouped as two variables.
I have been trying to use the reshape package (using melt and cast ) to do this and the best I could come up with was something which looked like the following:
id a b c d e f x y z
1 1 0 0 0 1 0 10 5 3
2 0 1 0 1 0 0 25 0 48
What I want to see is something like this:
x y z
a 10 5 3
b 25 0 48
I really would appreciate your help on this. I am a newbie to the reshape package.
Regards,
Arun