I have a data.frame that looks something like this:
table <- read.table(textConnection("W\tX\tY\tZ
A\t2\t3\t4
A\t2\t3\t6
A\t1\t2\t3
C\t3\t2\t1
B\t1\t3\t4
B\t1\t2\t2"),header=T)
I want to merge the rows that are equal for columns 1 to 3 (W,X,Y) and then keep all the values of column 4 (Z). The result should look like this:
W X Y Z
A 2 3 4,6
A 1 2 3
C 3 2 1
B 1 3 4
B 1 2 2
You see, the first two columns got merged, the rest didn't.