Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access output of multiple adjustments? #288

Open
christophsax opened this issue Apr 18, 2022 · 0 comments
Open

How to access output of multiple adjustments? #288

christophsax opened this issue Apr 18, 2022 · 0 comments
Labels

Comments

@christophsax
Copy link
Owner

Some questions on how to access output from seas_multi objects:

library(seasonal)
m <- seas(cbind(fdeaths, mdeaths))

most work fine:

head(final(m))
#>       fdeaths  mdeaths
#> [1,] 605.9811 1566.633
#> [2,] 538.6371 1514.975
#> [3,] 589.4354 1468.244
#> [4,] 606.7556 1678.065
#> [5,] 599.5486 1661.425
#> [6,] 547.2017 1557.990

but some don’t - the last one because the call element was addedt to the
output in 1.9:

head(residuals(m))
#> NULL
head(original(m))
#>      fdeaths mdeaths call.fdeaths call.mdeaths
#> [1,]     901    2134          901         2134
#> [2,]     689    1863          689         1863
#> [3,]     827    1877          827         1877
#> [4,]     677    1877          677         1877
#> [5,]     522    1492          522         1492
#> [6,]     406    1249          406         1249

@bcmonsell suggests in #278 that this should work:

z <- lapply(m, udg)
#> Error in FUN(X[[i]], ...): inherits(x, "seas") is not TRUE

This acually works:

z <- lapply(Filter(function(x) inherits(x, "seas"), m), udg)
head(z$fdeaths)
#> $date
#> [1] "Apr 18, 2022"
#> 
#> $time
#> [1] "22.55.59"
#> 
#> $version
#> [1] 1.1
#> 
#> $build
#> [1] 57
#> 
#> $output
#> [1] "html"
#> 
#> $srstit
#> [1] "ser1"

Or shorter, in R >= 4.1:

z <- lapply(Filter(\(x) inherits(x, "seas"), m), udg)

But perhaps we want all functions to work on both single and multiple objects? E.g., this:

# udg(m)

Perhaps as a data frame?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant