I am pretty new to R, so I am sorry in advance. Currently I am trying to add the columns of one table to another table. My first table contains general and financial data of thousands of different companies. The other table contains the tax rate of each country.
Table 1:
Company Name | Year | Country | Total Assets | EBIT | EBITDA | ... |
---|---|---|---|---|---|---|
ABC Company | 2017 | Germany | 75,000,000 | 25,000,000 | 35,000,000 | |
ABC Company | 2018 | Germany | 70,000,000 | 20,000,000 | 17,000,000 | |
DEF Company | 2017 | Germany | 30,000,000 | 5,000,000 | 20,000,000 | |
DEF Company | 2018 | Germany | 35,000,000 | 10,000,000 | 15,000,000 |
Table 2:
Country | Year | Tax rate |
---|---|---|
Germany | 2017 | 30% |
Germany | 2018 | 30% |
So I want to add the tax rate of each country to every row of table one, if t1$country=t2$country and t1$country=t2$country. But I need to match a row from table 2 multiple times with rows from table 1, since there are quite a few companies in the same country and the same year. I guess I need to use merge or something like an inner_join, but I am not very familiar with these things. Any help is appreciated.