Dear All,

i am solving the following problem in my work.

The first day from April 01 that gets more than 20 mm on a single day, or
totalled
over 2 consecutive days. i.e April 01 = 92th day of the year.

The column of interest is "Rain".
> head(Samaru56)
  Year Day Rain
1 1928   1    0
2 1928   2    0
3 1928   3    0
4 1928   4    0
5 1928   5    0
6 1928   6    0

I used the loop below but it is not printing anything.

sow_day=c()
for (i in 1928:1983){
  for (j in 92:366){
    k=j-1
    s_rain=Samaru56$Rain[k] + Samaru56$Rain[j]
    if (s_rain>=20)
      sow_day=j
      break
  }
  Samaru56$year=Samaru56$Year[sow_day]
  Samaru56$Day=Samaru56$Day[sow_day]
  Samaru56$Rain=Samaru56$Rain[sow_day]
}
sow_day

Any idea is welcome on how I can solve this problem. Thanks

-- 
Frederic Ntirenganya
Maseno University,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to