I have a dataset
<code>df
$MMM
$MMM$`WEOAGG:2024-04`
series_code
<char>
1: 001.BCA.us_dollars
2: 001.BCA_NGDPD.pcent_gdp
3: 001.BF.us_dollars
4: 001.BFD.us_dollars
5: 001.BFF.us_dollars
---
1660: 998.TTTPCH.pcent_change
1661: 998.TXGM_D.us_dollars_idx_2000_100
1662: 998.TXGM_DPCH.us_dollars_annual_pcent_change
1663: 998.TXG_RPCH.pcent_change
1664: 998.TX_RPCH.pcent_change
series_name
<char>
1: World – Current account balance (BCA) – U.S. dollars
2: World – Current account balance (BCA_NGDPD) – Percent of GDP
3: World – Financial account balance – U.S. dollars
4: World – Direct investment, net – U.S. dollars
5: World – Financial derivatives, net – U.S. dollars
---
1660: European Union – Terms of trade of goods – Percent change
1661: European Union – Export price of manufactures (TXGM_D) – U.S. dollars; index, 2000=100
1662: European Union – Export price of manufactures (TXGM_DPCH) – U.S. dollars; annual percent change
1663: European Union – Volume of exports of goods – Percent change
1664: European Union – Volume of exports of goods and services – Percent change
</code>
<code>df
$MMM
$MMM$`WEOAGG:2024-04`
series_code
<char>
1: 001.BCA.us_dollars
2: 001.BCA_NGDPD.pcent_gdp
3: 001.BF.us_dollars
4: 001.BFD.us_dollars
5: 001.BFF.us_dollars
---
1660: 998.TTTPCH.pcent_change
1661: 998.TXGM_D.us_dollars_idx_2000_100
1662: 998.TXGM_DPCH.us_dollars_annual_pcent_change
1663: 998.TXG_RPCH.pcent_change
1664: 998.TX_RPCH.pcent_change
series_name
<char>
1: World – Current account balance (BCA) – U.S. dollars
2: World – Current account balance (BCA_NGDPD) – Percent of GDP
3: World – Financial account balance – U.S. dollars
4: World – Direct investment, net – U.S. dollars
5: World – Financial derivatives, net – U.S. dollars
---
1660: European Union – Terms of trade of goods – Percent change
1661: European Union – Export price of manufactures (TXGM_D) – U.S. dollars; index, 2000=100
1662: European Union – Export price of manufactures (TXGM_DPCH) – U.S. dollars; annual percent change
1663: European Union – Volume of exports of goods – Percent change
1664: European Union – Volume of exports of goods and services – Percent change
</code>
df
$MMM
$MMM$`WEOAGG:2024-04`
series_code
<char>
1: 001.BCA.us_dollars
2: 001.BCA_NGDPD.pcent_gdp
3: 001.BF.us_dollars
4: 001.BFD.us_dollars
5: 001.BFF.us_dollars
---
1660: 998.TTTPCH.pcent_change
1661: 998.TXGM_D.us_dollars_idx_2000_100
1662: 998.TXGM_DPCH.us_dollars_annual_pcent_change
1663: 998.TXG_RPCH.pcent_change
1664: 998.TX_RPCH.pcent_change
series_name
<char>
1: World – Current account balance (BCA) – U.S. dollars
2: World – Current account balance (BCA_NGDPD) – Percent of GDP
3: World – Financial account balance – U.S. dollars
4: World – Direct investment, net – U.S. dollars
5: World – Financial derivatives, net – U.S. dollars
---
1660: European Union – Terms of trade of goods – Percent change
1661: European Union – Export price of manufactures (TXGM_D) – U.S. dollars; index, 2000=100
1662: European Union – Export price of manufactures (TXGM_DPCH) – U.S. dollars; annual percent change
1663: European Union – Volume of exports of goods – Percent change
1664: European Union – Volume of exports of goods and services – Percent change
where
<code>str(df)
List of 1
$ MMM:List of 1
..$ WEOAGG:2024-04:Classes ‘data.table’ and 'data.frame': 1664 obs. of 2 variables:
.. ..$ series_code: chr [1:1664] "001.BCA.us_dollars" "001.BCA_NGDPD.pcent_gdp" "001.BF.us_dollars" "001.BFD.us_dollars" ...
.. ..$ series_name: chr [1:1664] "World – Current account balance (BCA) – U.S. dollars" "World – Current account balance (BCA_NGDPD) – Percent of GDP" "World – Financial account balance – U.S. dollars" "World – Direct investment, net – U.S. dollars" ...
.. ..- attr(*, ".internal.selfref")=<externalptr>
</code>
<code>str(df)
List of 1
$ MMM:List of 1
..$ WEOAGG:2024-04:Classes ‘data.table’ and 'data.frame': 1664 obs. of 2 variables:
.. ..$ series_code: chr [1:1664] "001.BCA.us_dollars" "001.BCA_NGDPD.pcent_gdp" "001.BF.us_dollars" "001.BFD.us_dollars" ...
.. ..$ series_name: chr [1:1664] "World – Current account balance (BCA) – U.S. dollars" "World – Current account balance (BCA_NGDPD) – Percent of GDP" "World – Financial account balance – U.S. dollars" "World – Direct investment, net – U.S. dollars" ...
.. ..- attr(*, ".internal.selfref")=<externalptr>
</code>
str(df)
List of 1
$ MMM:List of 1
..$ WEOAGG:2024-04:Classes ‘data.table’ and 'data.frame': 1664 obs. of 2 variables:
.. ..$ series_code: chr [1:1664] "001.BCA.us_dollars" "001.BCA_NGDPD.pcent_gdp" "001.BF.us_dollars" "001.BFD.us_dollars" ...
.. ..$ series_name: chr [1:1664] "World – Current account balance (BCA) – U.S. dollars" "World – Current account balance (BCA_NGDPD) – Percent of GDP" "World – Financial account balance – U.S. dollars" "World – Direct investment, net – U.S. dollars" ...
.. ..- attr(*, ".internal.selfref")=<externalptr>
My goal is to extract from “df” the variables “series_code” and “series_name” and put them in two columns, where the first will be “series_code” (that will start from 1,2,3…up to 1664) and as second column “series_name” (that will start from 1,2,3… up to 1664)
Is there a way to do that?