Split an index into groups of indexes according to a factor, along either the levels or time periods of the index.
Arguments
- x
[piar_index]A price index, as made by, e.g.,elementary_index().- f
[factor | list]A factor or list of factors to group elements ofx.- drop
[logical(1)]Should levels that do not occur infbe dropped? By default all levels are kept.- ...
Further arguments passed to
split.default().- along
[character(1)]Either"levels"to split over the levels ofx(the default), or"time"to split over the time periods ofx.- value
[list]A list of values compatible with the splitting ofx, or something that can be coerced into one, recycled if necessary.
Value
split() returns a list of index objects for each level in f. The
replacement method replaces these values with the corresponding element of
value.
Examples
index <- as_index(matrix(1:6, 2))
split(index, 1:2)
#> $`1`
#> Period-over-period price index for 1 levels over 3 time periods
#> time
#> levels 1 2 3
#> 1 1 3 5
#>
#> $`2`
#> Period-over-period price index for 1 levels over 3 time periods
#> time
#> levels 1 2 3
#> 2 2 4 6
#>
split(index, c(1, 1, 2), along = "time")
#> $`1`
#> Period-over-period price index for 2 levels over 2 time periods
#> time
#> levels 1 2
#> 1 1 3
#> 2 2 4
#>
#> $`2`
#> Period-over-period price index for 2 levels over 1 time periods
#> time
#> levels 3
#> 1 5
#> 2 6
#>
