I keep extracting data from Eikon in the following format:
structure(list(GB0002404191 = c("DATE", "30/12/2022", "29/12/2022",
"28/12/2022", "23/12/2022", "22/12/2022", "21/12/2022", "20/12/2022",
"19/12/2022", "16/12/2022"), GB0002404191 = c("HIGH", "112.165",
"112.127", "112.088", "112.41", "112.767", "112.712", "112.867",
"113.963", "114.324"), GB0002404191 = c("LOW", "111.741", "111.821",
"111.453", "111.943", "112.064", "112.36", "112.203", "113.046",
"113.618"), GB0004893086 = c("DATE", "30/12/2022", "29/12/2022",
"28/12/2022", "23/12/2022", "22/12/2022", "21/12/2022", "20/12/2022",
"19/12/2022", "16/12/2022"), GB0004893086 = c("HIGH", "104.689",
"104.879", "104.724", "105.353", "105.678", "105.606", "105.785",
"107.244", "107.777"), GB0004893086 = c("LOW", "104.145", "104.21",
"103.849", "104.653", "104.756", "105.002", "104.683", "105.955",
"106.742"), GB0008932666 = c("DATE", "30/12/2022", "29/12/2022",
"28/12/2022", "23/12/2022", "22/12/2022", "21/12/2022", "20/12/2022",
"19/12/2022", "16/12/2022"), GB0008932666 = c("HIGH", "336.582",
"337.641", "336.927", "337.308", "336.603", "336.053", "336.624",
"341.35", "341.563"), GB0008932666 = c("LOW", "334.827", "335.018",
"333.571", "334.383", "335.119", "334.512", "333.98", "337.689",
"339.277"), GB0008983024 = c("DATE", "30/12/2022", "29/12/2022",
"28/12/2022", "23/12/2022", "22/12/2022", "21/12/2022", "20/12/2022",
"19/12/2022", "16/12/2022")), row.names = c(NA, -10L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x5649696b0a00>)
The column names are IDs, and the first row of data contains nested column names.
I want to change the data into the following format:
Where each group (ID) is stacked on top of each other and the values are the columns next to it.
When I look at this solution Reshaping data.frame from wide to long format I see that the issue with my data is that I have no clear defined id.vars as they have. My ID vars is the first row (not some set of columns).
Can someone please advise on how I can get the desired shape of the data.