year | month | category | id | value | ||||
2020 | 1 | category_x | 1 | 400 | ||||
2020 | 1 | category_x | 3 | 200 | ||||
2020 | 1 | category_x | 5 | 100 | ||||
2020 | 1 | category_y | 10 | 600 | ||||
2020 | 1 | category_z | 4 | 900 | ||||
. | . | . | . | . | ||||
. | . | . | . | . | ||||
. | . | . | . | . | ||||
2020 | 9 | category_x | 5 | 350 |
I would like to add for each category and its corresponding id variable a new observation for 2020 month 10 which would be the average of 2020 month 8 and 2020 month 7,
How can this be done when looping through the unique id numbers?
Thanks!
0 Response to Generating new observation for all id's in panel data
Post a Comment