You may pad the result with the value of your choice
padding is a keyword argument
- if you assign e.g. padding = missing, the result will be padded
- you may pad using any defined value and all types except Nothing
- example pads(missing, 0, nothing, NaN, 'โ ', AbstractString)
using RollingFunctions
๐ท๐๐ก๐ = [1, 2, 3, 4, 5]
๐น๐ข๐๐ = sum
๐๐๐๐ = 3
result = rolling(๐น๐ข๐๐, ๐ท๐๐ก๐, ๐๐๐๐; padding = missing);
#=
julia> result
5-element Vector{Union{Missing, Int64}}:
missing
missing
6
9
12
=#
result = rolling(๐น๐ข๐๐, ๐ท๐๐ก๐, ๐๐๐๐; padding = zero(eltype(๐ท๐๐ก๐));
#=
julia> result
5-element Vector{Int64}:
0
0
6
9
12
=#Give me the real values first, pad to the end.
result = rolling(๐น๐ข๐๐, ๐ท๐๐ก๐, ๐๐๐๐; padding = missing, padlast=true);
#=
julia> result
5-element Vector{Union{Missing,Int64}}:
6
9
12
missing
missing
=#technical aside: this is not the same as reverse(rolling(๐น๐ข๐๐,๐ท๐๐ก๐, ๐๐๐๐; padding = zero(eltype(๐ท๐๐ก๐)).