MattSandy

7/31/2015 - 2:56 AM

Breaks a vector into defined segment lengths

```
#Define the interval to cycle through
interval <- 30
#Replace sample_vector with your vector
sample_vector <- runif(100, 1, 10)
#Loop through each break in the sequence
for(i in seq(1,length(sample_vector),interval)) {
#Used to prevent the sequence from extending beyond the remainders
if(i+interval>=length(sample_vector)) {
#Vector access for this sequence is as follows:
print(sample_vector[i:length(sample_vector)])
} else {
#Vector access for this sequence is as follows:
print(sample_vector[i:(i+(interval-1))])
}
}
```