unitValues: Aggregates prices to unit values and quantities to sums

Description Usage Arguments Value Examples

View source: R/unitValues.R

Description

A function to aggregate price and quantity data to unit values

Usage

1
unitValues(x, pvar, qvar, pervar, prodID)

Arguments

x

A dataframe containing price, quantity, a time period identifier and a product identifier. It must have column names.

pvar

A character string for the name of the price variable

qvar

A character string for the name of the quantity variable

pervar

character string for the name of the time variable. This variable must contain integers starting at period 1 and increasing in increments of 1 period. There may be observations on multiple products for each time period.

prodID

A character string for the name of the product identifier

Value

A dataframe containing columns for product identifier, time period, quantities, and unit values.

Examples

1
2
3
4
5
6
7
# suppose the CES_sigma_2 dataset contains 12 monthly observations
# and suppose we want quarterly unit values.
df <- CES_sigma_2
# convert the monthly time variable into quarterly
df$time <- ceiling(CES_sigma_2$time/3)
# compute unit values using the quarterly time variable
unitValues(df,pvar="prices",qvar="quantities",pervar="time",prodID="prodID")

IndexNumR documentation built on Feb. 7, 2022, 5:09 p.m.