This funtion is an alias to the method iterate
and can be used to iterate
over all children of a hierarchical time series produced with perHts()
.
iterate(x, fun, asTable = FALSE, component = "", unnest = FALSE)
a hierarchical persephone object
a function with one argument
should the return value be coerced to a data.frame
?
a component id from which the iteration should start
should the return value be unnested, so that every component is an entry of the resulting list?
obj_x13 <- perX13(AirPassengers, "RSA3")
ht <- perHts(a = obj_x13, b = obj_x13, method = "x13")
ht2 <- perHts(a = ht, b = obj_x13)
ht2$iterate(function(x) {class(x)[1]})
#> $value
#> [1] "hierarchicalTimeSeries"
#>
#> $a
#> $a$value
#> [1] "hierarchicalTimeSeries"
#>
#> $a$a
#> $a$a$value
#> [1] "x13Single"
#>
#>
#> $a$b
#> $a$b$value
#> [1] "x13Single"
#>
#>
#>
#> $b
#> $b$value
#> [1] "x13Single"
#>
#>
ht2$iterate(function(x) {list(class = class(x)[1])}, asTable = TRUE)
#> component class
#> 1 hierarchicalTimeSeries
#> 2 a hierarchicalTimeSeries
#> 3 a/a x13Single
#> 4 a/b x13Single
#> 5 b x13Single
ht2$iterate(function(x) {list(class = class(x)[1])}, unnest = TRUE)
#> [[1]]
#> [[1]]$class
#> [1] "hierarchicalTimeSeries"
#>
#>
#> $a
#> $a$class
#> [1] "hierarchicalTimeSeries"
#>
#>
#> $`a/a`
#> $`a/a`$class
#> [1] "x13Single"
#>
#>
#> $`a/b`
#> $`a/b`$class
#> [1] "x13Single"
#>
#>
#> $b
#> $b$class
#> [1] "x13Single"
#>
#>