Re: [R] Sum of two consecutive number in dataset.

2014-10-19 Thread Frederic Ntirenganya
results in > >TRUE value > > > >Samaru56[sel,] > > > >selects these rows > > > >Regards > >Petr > > > >> -Original Message- > >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > >> project.org] O

Re: [R] Sum of two consecutive number in dataset.

2014-10-15 Thread Jeff Newmiller
ounces@r- >> project.org] On Behalf Of Frederic Ntirenganya >> Sent: Wednesday, October 15, 2014 9:01 AM >> To: r-help@r-project.org >> Subject: [R] Sum of two consecutive number in dataset. >> >> Dear All, >> >> i am solving the following problem in my w

Re: [R] Sum of two consecutive number in dataset.

2014-10-15 Thread William Dunlap
Break down your problem into parts: # compute two-day totals. I use filter here, but there are many ways twoDayTotal <- function (x, init = 0) { # init lets you supply rainfall from day previous to first in x filter(c(init, x), c(1, 1))[-length(x)] } # compute the first time a logical vect

Re: [R] Sum of two consecutive number in dataset.

2014-10-15 Thread Tom Wright
A couple of observations: 1) I'm not sure what the variable i is doing, looks like you are trying to loop through years but perhaps you left that bit of code out for clarity. 2) On the first loop of i you are assigning the values of Samaru56[sow_day,] to all values in Samaru56. For future loops all

Re: [R] Sum of two consecutive number in dataset.

2014-10-15 Thread Franklin Mairura
.org] On Behalf Of Frederic Ntirenganya > Sent: Wednesday, October 15, 2014 9:01 AM > To: r-help@r-project.org > Subject: [R] Sum of two consecutive number in dataset. > > Dear All, > > i am solving the following problem in my work. > > The first day from April 01 th

Re: [R] Sum of two consecutive number in dataset.

2014-10-15 Thread PIKAL Petr
om: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Frederic Ntirenganya > Sent: Wednesday, October 15, 2014 9:01 AM > To: r-help@r-project.org > Subject: [R] Sum of two consecutive number in dataset. > > Dear All, > > i am solving the foll

[R] Sum of two consecutive number in dataset.

2014-10-15 Thread Frederic Ntirenganya
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 10 2 1928 2