matched_index {PriceIndices}R Documentation

Providing the ratio of number of matched values from the indicated column to the number of all available values from this column

Description

The function returns a ratio of number of values from the indicated column that occur simultaneously in the compared periods or in a given time interval to the number of all available values from the above-mentioned column (defined by the type parameter) at the same time.

Usage

matched_index(data, period1, period2, type = "prodID", interval = FALSE)

Arguments

data

The user's data frame. It must contain a column time (as Date in format: year-month-day,e.g. '2020-12-01') and also a column indicated by the type parameter.

period1

The first period (as character) limited to the year and month, e.g. "2019-03".

period2

The second period (as character) limited to the year and month, e.g. "2019-04".

type

This parameter defines the column which is used in the procedure. Possible values of the type parameter are: retID, prodID, codeIN, codeOUT or description.

interval

A logical parameter indicating whether the procedure is to work for the whole time period between period1 and period2 (then it is TRUE).

Value

The function returns a ratio of number of values from the indicated column that occur simultaneously in the compared periods or in a given time interval to the number of all available values from the above-mentioned column (defined by the type parameter) at the same time. Possible values of the type parameter are: retID, prodID or description. If the interval parameter is set to FALSE, then the function compares only periods defined by period1 and period2. Otherwise the whole time period between period1 and period2 is considered. The returned value belongs to [0,1].

Examples

matched_index(milk, period1="2018-12", period2="2019-12", interval=TRUE)
matched_index(milk, period1="2018-12", period2="2019-12", type="retID")

[Package PriceIndices version 0.1.9 Index]