outlet_check: Reducing outlets

outlet_checkR Documentation

Reducing outlets

Description

The general purpose of the function is to determine in what proportion of the retail chain’s outlets the number of matched products within the analyzed time interval (or at its boundaries) exceeds a certain minimum specified by the user. The input data set (data frame) must contain matched products over time, i.e. it must contain the prodID column (as numeric, factor or character) and the grouping variable (i.e., an optional column) selected via by parameter.

Usage

outlet_check(
  data,
  start,
  end,
  by = c(),
  minN = 2,
  threshold = 0.9,
  interval = FALSE
)

Arguments

data

The user's data frame with information about sold products. It must contain columns: time (as Date in format: year-month-day,e.g. '2020-12-01') and, depending on next parameter values, columns: prodID or description, and retID.

start

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

end

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

by

This parameter specifies the name of the grouping column (as character). If the user does not specify any column via the by parameter, the outlet reduction will be performed without grouping.

minN

This parameter specifies the required minimum number of matched products present in a single outlet, within the grouping defined via the by parameter and within the specified time interval (or at its boundaries, depending on the interval parameter).

threshold

The lower bound of the acceptable fraction of complete outlets, i.e., outlets in which the number of matched products referred to above is not less than the minN level.

interval

A logical value indicating whether the reducing process concerns only two periods defined by start and end parameters (then the interval is set to FALSE) or whether that function is to reduce outlets during the whole time interval <start, end>.

Value

The function first determines the fraction of outlets (within subsets defined by the grouping column specified by the by parameter) that are complete, i.e., those containing at least minN matched products. If this fraction exceeds the value specified by threshold, a resulting data frame df is created consisting only of complete outlets, and the variable result is set to TRUE. Otherwise, df remains the original data, and the variable result is set to FALSE. The function returns a list consisting of the following elements: fraction (indicating the fraction of complete outlets), result, and df. This function can be used to automatically set the values of the data and outlets parameters in the final_index function.

Examples

outlet_reduction <- 
outlet_check(coffee, start="2018-12", end="2019-12",  
minN=3, by="description", interval=TRUE)
outlet_reduction$fraction
outlet_reduction$result
outlet_reduction$df

PriceIndices documentation built on April 7, 2026, 5:07 p.m.