I have a data frame as below :
A B
1 3
2 5
3 3
4 5
5 3
What I want to do is group the elements of A by B, as below:
B A's
3 1,3,5
5 2,4
I have a data frame as below :
A B
1 3
2 5
3 3
4 5
5 3
What I want to do is group the elements of A by B, as below:
B A's
3 1,3,5
5 2,4
We can try
library(data.table)
setDT(df1)[,.(As=toString(A)) , B]