I have a data frame that looks something like:
+-----------+---------+-------+-------+-------+
| | | Day 1 | Day 2 | Day 3 |
+-----------+---------+-------+-------+-------+
| Product 1 | Revenue | 0 | 0 | 0 |
| | Cost | 0 | 0 | 0 |
| Product 2 | Revenue | 0 | 0 | 0 |
| | Cost | 0 | 0 | 0 |
| Product 3 | Revenue | 0 | 0 | 0 |
| | Cost | 0 | 0 | 0 |
+-----------+---------+-------+-------+-------+
Essentially a two level index on the vertical. The first level is the product and the second either revenue or cost.
I would like to add a Profit row to all products below Revenue and Cost (simply Revenue - Cost). Or even the average of that products Revenue etc. However, after much experimentation with apply, I cannot seem to get this to work with the multi levels.
Product 1 Revenue 0
Cost 0
Profit 0
How could this be achieved?