A small query,
I have dataset like this
dataset <- data.frame("X"=sample(x = 100:1150,size = 100),"Y"=NA)
X Y
1 809 NA
2 521 NA #NA changed to 1, because cumulative sum of X exceeded (809+521+607 > 1440)
3 607 NA
4 163 NA #NA changed to 1, because cumulative sum of X exceeded (521+607+163+179 > 1440)
5 179 NA
6 647 NA #NA changed to 1, because cumulative sum of X exceeded (163+179+647+1086 > 1440)
7 1086 NA #NA changed to 1, because cumulative sum of X exceeded (1086 + 574 > 1440)
8 574 NA
9 390 NA #NA changed to 1, because cumulative sum of X exceeded (574 + 390 +864 > 1440)
10 864 NA #NA changed to 1, because cumulative sum of X exceeded (864 + 578 > 1440)
11 578 NA #NA changed to 1, because cumulative sum of X exceeded (578 +890 > 1440)
12 890 NA #NA changed to 1, because cumulative sum of X exceeded (890 + 1004 > 1440)
13 1004 NA #NA changed to 1, because cumulative sum of X exceeded (1004+906 > 1440)
14 906 NA
15 391 NA
how can I change Y to 1 when cumulative sum of X+1 term exceeds 1440.
Thank you for your time.