I'm new to R and needed some help with reshaping a data frame that is similar to the one below:
company_name | year | profit_usd | profit_eur | profit_gbp |
---|---|---|---|---|
A | 2017 | 1237 | 1006 | 871 |
B | 2017 | 1337 | 1096 | 949 |
A | 2018 | 1143 | 937 | 811 |
B | 2018 | 1288 | 1056 | 914 |
I want to reshape this table such that I have only one column which shows profit and another column which shows the currency name. Something like this:
company_name | year | currency | profit |
---|---|---|---|
A | 2017 | usd | 1237 |
A | 2017 | eur | 1006 |
A | 2017 | gbp | 871 |
B | 2017 | usd | 1337 |
B | 2017 | eur | 1096 |
B | 2017 | gbp | 949 |
A | 2018 | usd | 1143 |
A | 2018 | eur | 937 |
A | 2018 | gbp | 811 |
B | 2018 | usd | 1288 |
B | 2018 | eur | 1056 |
B | 2018 | gbp | 914 |
Any help with this would be greatly appreciated, thank you!