I have a data set shaped like the following:
Buyer | Broker | Brand
I am trying to use aggregate to count the number of Buyers by Broker and Brand to quantify market share. It should look like this:
Broker | Brand | Buyer_Count
Acme | Nike | 50
Acme | Reebok | 20
Acme | Converse | 30
Megacorp | Nike | 80
Megacorp | Reebok | 120
...
I am using:
Agg <- aggregate(Buyer ~ Broker + Brand, data = mydata, fun=count)
and it says
"Error in UseMethod("groups") : no applicable method for 'groups' applied to an object of class "character" "
I am pretty sure the issue is "fun = count"
not being the correct function but am not sure what the correct function would be here.
I tried match.fun(count)
but did not get one that works there either. I also tried google and didn't find anything.
Thank you in advance.