0
In R, I have the following data:
entrada saida id ordem
2013-01-15 2013-05-20 1 1
2015-03-13 2015-09-12 1 2
2016-01-12 2016-04-11 1 3
I want to add a column with the difference (days) between the output (1) and the input (2) and so on, considering the id and the order of the records. Follow an example:
entrada saida id ordem diferenca
2013-01-15 2013-05-20 1 1
2015-03-13 2015-09-12 1 2 662
2016-01-12 2016-04-11 1 3 122
2013-01-01 2013-01-30 2 1
2014-06-18 2015-09-02 2 2 504
2016-02-26 2017-02-11 2 3 177
2018-03-04 2018-12-16 2 4 386
It is not a duplicate. I want to calculate the difference of dates located in different columns and rows.
– Marli Rocha
So the question has to be clearer. How is there a difference of zero days? What are the dates that enter into the calculation of each column value
diferenca
?– Rui Barradas
Rui, thanks for the tip. I edited the example, and took out the zero. The difference is between the date of departure (e.g. 2013-05-20) and the next entry (e.g. 2015-03-13), and so on.
– Marli Rocha