% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f_data_processing.R
\name{outlet_check}
\alias{outlet_check}
\title{Reducing outlets}
\usage{
outlet_check(
  data,
  start,
  end,
  by = c(),
  minN = 2,
  threshold = 0.9,
  interval = FALSE
)
}
\arguments{
\item{data}{The user's data frame with information about sold products. It must contain columns: \code{time} (as Date in format: year-month-day,e.g. '2020-12-01') and, depending on next parameter values, columns: \code{prodID} or \code{description}, and \code{retID}.}

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

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

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

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

\item{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 \code{minN} level.}

\item{interval}{A logical value indicating whether the reducing process concerns only two periods defined by \code{start} and \code{end} parameters (then the \code{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 \code{by} parameter) that are complete, i.e., those containing at least \code{minN} matched products. If this fraction exceeds the value specified by \code{threshold}, a resulting data frame \code{df} is created consisting only of complete outlets, and the variable \code{result} is set to TRUE. Otherwise, df remains the original \code{data}, and the variable \code{result} is set to FALSE. The function returns a list consisting of the following elements: \code{fraction} (indicating the fraction of complete outlets), \code{result}, and \code{df}. This function can be used to automatically set the values of the \code{data} and \code{outlets} parameters in the \code{final_index} function.
}
\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 \code{prodID} column (as numeric, factor or character) and the grouping variable (i.e., an optional column) selected via \code{by} parameter.
}
\examples{
\donttest{outlet_reduction <- 
outlet_check(coffee, start="2018-12", end="2019-12",  
minN=3, by="description", interval=TRUE)}
\donttest{outlet_reduction$fraction}
\donttest{outlet_reduction$result}
\donttest{outlet_reduction$df}
}
