1
I have a table in the R of people, countries and days. I need to subtract the amount of people from the previous day from the current day column for all columns, someone can help me?
I need to make the following formula in an automated way
05/11/20 = 05/11/20 - 04/11/20 para todas as linhas
04/11/20 = 04/11/20 - 03/11/20 para todas as linhas
03/11/20 = 03/11/20 - 02/11/20 para todas as linhas
02/11/20 = 02/11/20 - 01/11/20 para todas as linhas
I tried something like this, but it doesn’t work
mutate([c(4)] = [c(4)] - [c(4 - 1)]))
After this formula would put inside a loop to change the columns
In case the first table always shows the total number of people, need to know the amount day by day.
My base is like this:
Países 01/11/2020 02/11/2020 03/11/2020 04/11/2020 05/11/2020 06/11/2020
Brasil 1 1 2 3 5 7
Chile 2 2 2 4 4 5
US 0 0 0 1 2 3
México 0 0 0 0 1 1
I need her like this:
Países 01/11/2020 02/11/2020 03/11/2020 04/11/2020 05/11/2020 06/11/2020
Brasil 1 0 1 1 2 2
Chile 2 0 0 2 0 1
US 0 0 0 1 1 1
México 0 0 0 0 1 0