i have a data frame that looks like this
Time DT5.0_Prediction
20:10:36.051 IST 3
20:10:36.150 IST 3
20:10:36.251 IST 3
20:10:36.350 IST 3
20:10:36.450 IST 3
20:10:36.551 IST 1
20:10:36.651 IST 1
20:10:36.750 IST 1
20:10:36.851 IST 3
20:10:36.952 IST 1
20:10:37.051 IST 1
20:10:37.151 IST 1
20:10:37.252 IST 1
20:10:37.351 IST 3
20:10:37.452 IST 1
20:10:37.551 IST 1
20:10:37.652 IST 1
20:10:37.752 IST 3
20:10:37.853 IST 1
20:10:37.953 IST 1
20:10:38.053 IST 1
20:10:38.152 IST 1
20:10:38.252 IST 1
20:10:38.352 IST 1
20:10:38.453 IST 1
20:10:38.554 IST 1
I want to use window size of 10 and get the data to be like this
Starting Time Ending time Mode
20:10:36.051 IST 20:10:36.952 IST 3
20:10:37.051 IST 20:10:37.953 IST 1
20:10:38.053 IST 20:10:38.955 IST 1
and so on
In mode column from the above table, the number "3" is the most number of times repeated in that particular window and "1" is the most number of times repeated in the next consecutive window.
i used the following code
a <- 1
for(i in 1: length(mydata[,2])){
b <- a+99
mydata$StartTime [i] <- mydata$Time[a]
mydata$EndTime [i] <- mydata$Time[b]
mydata$mode1234567 [i] <- ifelse( b <= nrow(mydata),
count(mydata[a:min(b, nrow(mydata)),2]),
NA)
a <- b+1
}
using frequency and count is wrong...
thanks in advance