stack.piar_index {piar} | R Documentation |
Stack price indexes
Description
stack()
combines two price indexes with common levels, stacking index
values and percent-change contributions for one index after the other.
unstack()
breaks up a price index into a list of indexes for each
time period.
These methods can be used in a map-reduce to make an index with multiple aggregation structures (like a Paasche index).
Usage
## S3 method for class 'piar_index'
stack(x, y, ...)
## S3 method for class 'piar_index'
unstack(x, ...)
Arguments
x |
A price index, as made by, e.g., |
y |
A price index, or something that can coerced into one. If |
... |
Not currently used. |
Value
A price index that inherits from chainable_piar_index
if x
is a
period-over-period index, or direct_piar_index
if x
is a fixed-base
index. If both x
and y
are aggregate indexes then the result will also
inherit from aggregate_piar_index
.
unstack()
returns a list of price indexes with the same class as x
.
Note
It may be necessary to use rebase()
prior to stacking fixed-based price
indexes to ensure they have the same base period.
See Also
Other index methods:
[.piar_index()
,
aggregate.piar_index()
,
as.data.frame.piar_index()
,
chain()
,
contrib()
,
head.piar_index()
,
is.na.piar_index()
,
levels.piar_index()
,
mean.piar_index()
,
merge.piar_index()
,
split.piar_index()
,
time.piar_index()
,
vcov.aggregate_piar_index()
Examples
index1 <- as_index(matrix(1:6, 2))
index2 <- index1
time(index2) <- 4:6
stack(index1, index2)
# Unstack does the reverse
all.equal(
c(unstack(index1), unstack(index2)),
unstack(stack(index1, index2))
)