Description Usage Arguments Details Value Examples
This function calculates the best discount based on
analyseShoppingCart(), enumerateCombinations() and
extractDiscountSets(). It needs the output of the last mentioned
function. Additionally information are required about the price of one item
and the discount prices.
1 2 | calculateBestDiscount(discountSets, discountInfos, pricePerItem,
intermediateSteps = FALSE)
|
discountSets |
|
discountInfos |
|
pricePerItem |
numerical price for one item; Currently only one price is allowed |
intermediateSteps |
logical; if it's set to |
Currently the argument discountInfos needs one special format: It
needs two columns:
1. The first one is called set and contains numerical information
about the discount sets' possibilities (read examples)
2. The second one is called discount and contains numerical
information about the discount.
Depending on intermediateSteps, only a numerical vector is
returned or a list which additionally contains the intermediate steps.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ```
# These books are available in the shop
books <- dplyr::tibble(
itemID = 1:5,
name = c(
"Stein der Weisen",
"Kammer des Schreckens",
"Gefangene von Askaban",
"Feuerkelch",
"Orden des Phönix"
)
)
set.seed(1)
shoppingCart <- dplyr::sample_n(books, 15, replace = TRUE) %>%
dplyr::arrange(itemID)
ls <- analyseShoppingCart(shoppingCart, itemID, name)
alternatives <- enumerateCombinations(ls)
discountSets <- extractDiscountSets(alternatives)
discountInfos <- dplyr::tibble(
set = 1:5,
discount = c(0, 5, 10, 20, 25)
)
calculateBestDiscount(
correctDiscountSets, discountInfos, pricePerItem = 8
)
```
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.