I have a dataset where I want to take both the normal 'mean' and the weighted mean by group. Each group can be considered a different portfolio or stock, price is the price of that portfolio or stock, size is the shares, gain is the return in percentage, and so market cap would be price*size. I have a dataset where I want to take both the