I have a data frame that contains the following format:
manufacturers pricegroup leads
harley <2500
honda <5000
... ... ..
I use the aggregate function to output data as follows:
aggregate( leads ~ manufacturer + pricegroup, data=leaddata,
FUN=sum, subset=(manufacturer==c("honda","harley")))
I noticed that this does not return the correct results. The numbers for each manufacturer are getting smaller and smaller, the more manufacturers I add to the group of subsets. However, if I use:
aggregate( leads ~ manufacturer + pricegroup, data=leaddata,
FUN=sum, subset=(manufacturer=="honda" | manufacturer=="harley"))
It returns the correct numbers. For my life, I canβt understand why. I would just use the OR operator, except that I will dynamically translate the list of manufacturers. Any thoughts on why the first design doesn't work? Better, any thoughts on how to make it work? Thank!