Skip to contents

Combine two price indexes with common time periods, merging together the index values and percent-change contributions for each time period.

This is useful for building up an index when different elemental aggregates come from different sources of data, or use different index-number formulas.

Usage

# S3 method for class 'chainable_piar_index'
merge(x, y, ...)

# S3 method for class 'direct_piar_index'
merge(x, y, ...)

Arguments

x

A price index, as made by, e.g., elemental_index().

y

A price index, or something that can coerced into one. If x is a period-over-period index then y is coerced into a chainable index; otherwise, y is coerced into a direct index.

...

Not currently used.

Value

A combined price index that inherits from the same class as x.

Examples

index1 <- as_index(matrix(1:6, 2))

index2 <- index1
levels(index2) <- 3:4

merge(index1, index2)
#> Period-over-period price index for 4 levels over 3 time periods 
#>   1 2 3
#> 1 1 3 5
#> 2 2 4 6
#> 3 1 3 5
#> 4 2 4 6