How to sum up value based on previous rows in R
Hi all,
I have this dataset.
Value Date Type Difference Increase or Decrease
1 55.55556 2018-09-21 ESVI 0.0000000 0
2 51.11111 2018-10-03 ESVI -4.4444444 -1
3 52.88889 2018-11-08 ESVI 1.7777778 1
4 53.33333 2018-11-20 ESVI 0.4444444 1
5 51.66667 2018-12-02 ESVI -1.6666667 -1
6 52.44444 2018-12-14 ESVI 0.7777778 1
7 52.66667 2018-12-26 ESVI 0.2222222 1
8 53.77778 2019-01-07 ESVI 1.1111111 1
9 53.88889 2019-01-19 ESVI 0.1111111 1
10 52.88889 2019-01-31 ESVI -1.0000000 -1
11 48.55556 2019-02-12 ESVI -4.3333333 -1
12 44.55556 2019-02-24 ESVI -4.0000000 -1
13 42.11111 2019-03-08 ESVI -2.4444444 -1
14 35.44444 2019-03-20 ESVI -6.6666667 -1
15 31.66667 2019-04-01 ESVI -3.7777778 -1
16 30.66667 2019-04-13 ESVI -1.0000000 -1
17 28.66667 2019-04-25 ESVI -2.0000000 -1
18 29.11111 2019-05-07 ESVI 0.4444444 1
19 31.33333 2019-05-19 ESVI 2.2222222 1
20 33.88889 2019-05-31 ESVI 2.5555556 1
21 36.44444 2019-06-12 ESVI 2.5555556 1
22 38.11111 2019-06-24 ESVI 1.6666667 1
23 36.33333 2019-07-30 ESVI -1.7777778 -1
24 35.44444 2019-08-11 ESVI -0.8888889 -1
25 42.22222 2019-08-23 ESVI 6.7777778 1
26 49.00000 2019-09-04 ESVI 6.7777778 1
27 48.11111 2019-09-16 ESVI -0.8888889 -1
28 40.11111 2019-09-28 ESVI -8.0000000 -1
29 32.33333 2019-10-04 ESVI -7.7777778 -1
30 33.88889 2019-10-10 ESVI 1.5555556 1
31 35.44444 2019-10-16 ESVI 1.5555556 1
32 35.33333 2019-10-22 ESVI -0.1111111 -1
33 34.44444 2019-10-28 ESVI -0.8888889 -1
I would like to sum the difference values eachtime the difference progressively decreases
For example: row number 10 to 17, row number 23 to 24 row number 27 to 29 and row number 32 to 33
Is there anyway to do this please?
Any help will be greatly appreciated.
Thanks very much,
Ishack
• 618 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Hello ishackm!
We believe that this post does not fit the main topic of this site.
Does not look like a bioinformatics question
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!