Make calculations across 2 different data frames

Viewed 20

I have 2 data frames DF1 and DF2, then have similar date range and variables names, but for sure the meaning is different.

DF1

Date      name1   name2   name3   name4   name5   name6   name7
2022/05  85.37    30.30   108.86  14.67   23.90   77.62   23.30
2022/06  44.00    85.00   113.20  16.28   20.40   56.97   77.85
2022/07  37.36    85.00   113.20  16.28   35.68   74.86   43.34
2022/08  41.34    36.34   184.90  20.70   58.79   30.34   72.38

DF2

Date      name1   name2   name3   name4   name5   name6   name7
2022/05   100     178    140      100     178     100   140
2022/06   140     140    178      140     140     140   140
2022/07   178     178    140      178     100     178   178
2022/08   178     140    140      140     140     178   178

For each variable I need to calculate a share of DF1 from DF2.

Date      name1     name2   name3   name4   name5   name6   name7
2022/05   85.37/100    
2022/06   44.00/140     etc.

For sure, there is a possibility to merge the files and then use dplyr to calculate the percentage variable by variable, but may be there is a shorter way?

0 Answers
Related