Time Velocity
0 0
1.5 1.21
3 1.26
4.5 1.31
6 1.36
7.5 1.41
9 1.46
10.5 1.51
12 1.56
13 1.61
14 1.66
15 1.71
16 1.76
17 1.81
18 1.86
19 1.91
20 1.96
21 2.01
22.5 2.06
24 2.11
25.5 2.16
27 2.21
28.5 2.26
30 2.31
31.5 2.36
33 2.41
34.5 2.4223
36 2.4323
So I have data about Time and Velocity...I want to use the cut or the which function to separate my data into 6 min intervals...my Maximum Time usually goes up to 3000 mins So I would want the output to be similar to this...
Time Velocity
0 0
1.5 1.21
3 1.26
4.5 1.31
6 1.36
Time Velocity
6 1.36
7.5 1.41
9 1.46
10.5 1.51
12 1.56
Time Velocity
12 1.56
13 1.61
14 1.66
15 1.71
16 1.76
17 1.81
18 1.86
So what I did so far is read the data using data=read.delim("clipboard") I decided to use the function 'which'....but I would need to do it for up 3000 mins etc
dat <- data[which(data$Time>=0
& data$Time < 6),],
dat1 <- data[which(data$Time>=6
& data$Time < 12),]
etc But this wouldn't be so convenient if I had time to went up to 3000 mins Also I would want all my results to be contained in one output/ variable
Thanks guys
I don't think that you want to get duplicated bounds. here A simple solution without using
cut
( similar to @Mathew solution).I will assume here that you really don't want to duplicate the values across the bins.
If you really need duplicates timestamps that are integral multipes of 6 then you will have to do some data duplication before splitting.