I want to split my data frame by looping through rows and subsetting
indices = (diff(Data$Time>1800))
for (i in 1:length(indices)){
if(indices[i]==TRUE){
##### I need a function to split data by row index
}}
I tried
lst <- split(Data, as.factor(diff(Data$Time>1800)==TRUE))
But it returns only rows that are true, but what i want is to split each time it faces true.
This is what I have
Time temp
7/1/17 13:45:34 56
7/1/17 13:45:37 68
7/1/17 13:45:39 98
7/1/17 13:45:40 99
7/1/17 13:45:46 97
7/1/17 14:16:29 48
7/1/17 14:16:30 78
7/1/17 14:16:31 66
7/1/17 14:17:34 93
7/1/17 14:17:39 98
7/1/17 14:17:40 98
7/1/17 14:17:44 93
7/1/17 14:47:10 54
7/1/17 14:47:12 67
7/1/17 14:47:16 69
7/1/17 14:47:18 95
7/1/17 14:47:19 95
7/1/17 14:47:23 96
7/1/17 14:47:28 96
7/1/17 14:47:30 99
This is what I want
Time temp
7/1/17 13:45:34 56
7/1/17 13:45:37 68
7/1/17 13:45:39 98
7/1/17 13:45:40 99
7/1/17 13:45:46 97
Time temp
7/1/17 14:16:29 48
7/1/17 14:16:30 78
7/1/17 14:16:31 66
7/1/17 14:17:34 93
7/1/17 14:17:39 98
7/1/17 14:17:40 98
7/1/17 14:17:44 93
Time temp
7/1/17 14:47:10 54
7/1/17 14:47:12 67
7/1/17 14:47:16 69
7/1/17 14:47:18 95
7/1/17 14:47:19 95
7/1/17 14:47:23 96
7/1/17 14:47:28 96
7/1/17 14:47:30 99
Is it possible to split my data by storing these indexes in a vector and then splitting data frame based on this vector, which means whenever the row number is equal to our value " i " split the data frame at that row. So as to have multiple data frames.