I have a two-level multilevel data. Below is an example of it. I have two participants that reported their fruits consumption for two days.
id day apple orange
1   1    34     12
1   2    54     43
2   1    65     56
2   2    87     81
I want to restructure the dataframe from 2-level data to 3-level data. I want to a) make a variable for type of fruit; b) nest fruit consumption in days in one column. So the dataframe looks like below:
id day fruit_type fruit_consumption
1   1      apple                34
1   1     orange                12
1   2      apple                54
1   2     orange                43
2   1      apple                65
2   1     orange                56
2   2      apple                87
2   2     orange                81
 
    