data_norm {PriceIndices} | R Documentation |
Normalization of grammage units and recalculation of prices and quantities with respect to these units
Description
The function normalizes grammage units of products and recalculates product prices and quantities with respect to these normalized grammage units.
Usage
data_norm(
data = data.frame(),
rules = list(c("ml", "l", 1000), c("g", "kg", 1000)),
all = TRUE
)
Arguments
data |
The user's data frame. The data frame must contain the following columns: |
rules |
User rules for transforming |
all |
A logical value indicating whether the resulting data frame is to be limited to products with detected grammage. Its default value is |
Value
The function returns the user's data frame with two transformed columns: grammage
and unit
, and two rescaled columns: prices
and quantities
. The above-mentioned transformation and rescaling take into consideration the user rules
. Recalculated prices and quantities concern grammage units defined as the second parameter in the given rule.
Examples
# Preparing a data set
data<-data_unit(dataU, units=c("g|ml|kg|l"), multiplication="x")
# Normalization of grammage units
data_norm(data, rules=list(c("ml","l",1000), c("g","kg",1000)))