I am trying to the following in R.
I have a data frame with time(hour) and the second column has either zero or one. Time interval between consecutive time step is 1 hour. It would be easier if I could attach a sample file but don't know how to attach one. I am trying to find out how many 1's occur which are 24-hour apart. More than one "1" in a 24 hour period is considered a "1"
Let's assume a counter, cnt is initialized at 0.
I want to compare each of row in the second column to the second column values in 24 hour window. If there is more than one "1" in any 24-hour period, it implies that there is one "1" in that 24-hour window.
In FORTRAN, I would set up a counter, go to each time step, compare the value for the next 24 hours/time steps. If a "1" is found, for the first "1" would increase the counter by 1. If there is another "1" in the same 24-hour period, I would not increase the counter any more and move to the next row and keep doing so until the end of the file.
Hopefully, I could explain what I want. If it's not clear, let me know. Think something can be done by the match() function or the plyr package but cannot find out.