KOF-ch / tstools

A time series toolbox for official statistics
11 stars 4 forks source link

long_to_ts needs na.trim to be optional #289

Closed mbannert closed 5 years ago

mbannert commented 5 years ago

Easy fix:

if(strip_nas) lapply(tsl, na.trim) 

@HomoCodens didn't you state in another issue / PR lately we shouldn't use na.trim in the package for some reason or do I mix things up here? I just raise this here, because when I account for this issue here, I'd like to use the state-of-the-art na trimmer :)

HomoCodens commented 5 years ago

Exactly.

For some reason zoo::na.trim shifts yearly ts objects one period into the future. This is because internally it uses as.zoo on them and this happens:

# Yearly series are the issue
zoo::as.zoo(ts(1:4,
               start = 2018+11/12,
               end = 2021+11/12,
               frequency = 1))
#> 2019 2020 2021 2022 
#>    1    2    3    4