I have a data set something like this:
~product_name, ~id, ~clicks,
"A", 1, 1,
"A", 4, 1,
"A", 3, 1,
"B", 4, 2,
"B", 6, 2,
"C", 3, 3,
"C", 5, 3,
"D", 6, 4,
"D", 4, 4,
"D", 3, 4,
)
Now, I want to aggregate it by making an array list for the id. Here is my desired data:
df_A <- tribble(
~product_name, ~id, ~clicks,
"A", 1,4,3, 1,
"B", 4,6, 2,
"C", 3,5, 3,
"D", 6,4,3, 4,
)
How can I do that?