Skip to contents

This function generates a list of of sliding windows conditional on two parameters: the length of each window (number of samples) and the total number of samples present in the data.

Usage

window_list(window_size, length, window_step = 1)

Arguments

window_size

An integer number specifying the number of samples per window.

length

An integer number specifying the total number of samples.

window_step

Optional; an integer number specifying the distance between the first entry of adjacent windows. Default is window_step=1.

Value

A list of samples of sample indices. Each list entry represents one window.

Examples

window_list(window_size = 6, length = 40)
#> [[1]]
#> [1] 1 2 3 4 5 6
#> 
#> [[2]]
#> [1] 2 3 4 5 6 7
#> 
#> [[3]]
#> [1] 3 4 5 6 7 8
#> 
#> [[4]]
#> [1] 4 5 6 7 8 9
#> 
#> [[5]]
#> [1]  5  6  7  8  9 10
#> 
#> [[6]]
#> [1]  6  7  8  9 10 11
#> 
#> [[7]]
#> [1]  7  8  9 10 11 12
#> 
#> [[8]]
#> [1]  8  9 10 11 12 13
#> 
#> [[9]]
#> [1]  9 10 11 12 13 14
#> 
#> [[10]]
#> [1] 10 11 12 13 14 15
#> 
#> [[11]]
#> [1] 11 12 13 14 15 16
#> 
#> [[12]]
#> [1] 12 13 14 15 16 17
#> 
#> [[13]]
#> [1] 13 14 15 16 17 18
#> 
#> [[14]]
#> [1] 14 15 16 17 18 19
#> 
#> [[15]]
#> [1] 15 16 17 18 19 20
#> 
#> [[16]]
#> [1] 16 17 18 19 20 21
#> 
#> [[17]]
#> [1] 17 18 19 20 21 22
#> 
#> [[18]]
#> [1] 18 19 20 21 22 23
#> 
#> [[19]]
#> [1] 19 20 21 22 23 24
#> 
#> [[20]]
#> [1] 20 21 22 23 24 25
#> 
#> [[21]]
#> [1] 21 22 23 24 25 26
#> 
#> [[22]]
#> [1] 22 23 24 25 26 27
#> 
#> [[23]]
#> [1] 23 24 25 26 27 28
#> 
#> [[24]]
#> [1] 24 25 26 27 28 29
#> 
#> [[25]]
#> [1] 25 26 27 28 29 30
#> 
#> [[26]]
#> [1] 26 27 28 29 30 31
#> 
#> [[27]]
#> [1] 27 28 29 30 31 32
#> 
#> [[28]]
#> [1] 28 29 30 31 32 33
#> 
#> [[29]]
#> [1] 29 30 31 32 33 34
#> 
#> [[30]]
#> [1] 30 31 32 33 34 35
#> 
#> [[31]]
#> [1] 31 32 33 34 35 36
#> 
#> [[32]]
#> [1] 32 33 34 35 36 37
#> 
#> [[33]]
#> [1] 33 34 35 36 37 38
#> 
#> [[34]]
#> [1] 34 35 36 37 38 39
#> 
#> [[35]]
#> [1] 35 36 37 38 39 40
#> 
window_list(window_size = 6, length = 40, window_step = 2)
#> [[1]]
#> [1] 1 2 3 4 5 6
#> 
#> [[2]]
#> [1] 3 4 5 6 7 8
#> 
#> [[3]]
#> [1]  5  6  7  8  9 10
#> 
#> [[4]]
#> [1]  7  8  9 10 11 12
#> 
#> [[5]]
#> [1]  9 10 11 12 13 14
#> 
#> [[6]]
#> [1] 11 12 13 14 15 16
#> 
#> [[7]]
#> [1] 13 14 15 16 17 18
#> 
#> [[8]]
#> [1] 15 16 17 18 19 20
#> 
#> [[9]]
#> [1] 17 18 19 20 21 22
#> 
#> [[10]]
#> [1] 19 20 21 22 23 24
#> 
#> [[11]]
#> [1] 21 22 23 24 25 26
#> 
#> [[12]]
#> [1] 23 24 25 26 27 28
#> 
#> [[13]]
#> [1] 25 26 27 28 29 30
#> 
#> [[14]]
#> [1] 27 28 29 30 31 32
#> 
#> [[15]]
#> [1] 29 30 31 32 33 34
#> 
#> [[16]]
#> [1] 31 32 33 34 35 36
#> 
#> [[17]]
#> [1] 33 34 35 36 37 38
#> 
#> [[18]]
#> [1] 35 36 37 38 39 40
#>