'Compute difference between weekly values b country

I need to find out what is the excess death (defined as the difference between deaths that occurred in a specific week) / country

my table looks something like this:

Country Dates Death_in_2020 Death_in_2021

Germany 01.01 1700          1800

Germany 01.08 1800          1900

Finland 01.06 1346          1448

Finland 08.06 1444          1555

My first idea was to sort the data frame by date and country.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source