# three -------------------------------------
# initialise list
path <- system.file("testdata", "three3", package = "mm.reoptimise")
scenario <- create_scenario(path)
scenario_list <- list(scenario)
# Test if no scenarios are ran yet
# test function
test_that("output is correct", {
df <- create_all_scenarios_table(scenario_list)
expect_equal(nrow(df), 0)
expect_equal(class(df)[1], "tbl_df")
})
# make a new scenario
myscenario_profit <- set_scenario(scenario_list[[1]],
period = "month",
budget = 3.8e7,
kpi1 = "Profit",
kpi2 = "Profit",
kpi3 = "Profit")
myscenario_profit <- run_optimization(
scenario = myscenario_profit)
# add new scenario to the list
myname <- "my new net profit scenario"
scenario_list <- add_scenario(scenario_list, myscenario_profit, myname)
# test function
test_that("output is correct", {
all_scenarios_table <- create_all_scenarios_table(scenario_list)
check <- check_scenario_result_present(scenario_list)
expect_true(is.data.frame(all_scenarios_table))
expect_equal(unique(all_scenarios_table$scenario_name), list_out_scenarios(scenario_list)[check])
})
# chart_comparison_overview(all_scenarios_table,
# "my new net profit scenario",
# 1, 1, 1, "month")
# TNZ ----------------------------------------
# initialise list
path <- system.file("testdata", "tnz1" ,"scenario_0", package = "mm.reoptimise")
scenario <- create_scenario(path)
scenario_list <- list(scenario)
# Test if no scenarios are ran yet
# test function
test_that("output is correct", {
df <- create_all_scenarios_table(scenario_list)
expect_equal(nrow(df), 0)
expect_equal(class(df)[1], "tbl_df")
})
get_scenario_kpi1(scenario, period = "Annual")
# make a new scenario
myscenario <- set_scenario(scenario_list[[1]],
period = get_scenario_period(scenario)[1],
budget = get_scenario_budget(scenario),
kpi1 = "Revenue")
myscenario <- run_optimization(
scenario = myscenario)
# add new scenario to the list
myname <- "MYscenario"
scenario_list <- add_scenario(scenario_list, myscenario, myname)
# test function
test_that("output is correct", {
all_scenarios_table <- create_all_scenarios_table(scenario_list)
check <- check_scenario_result_present(scenario_list)
expect_true(is.data.frame(all_scenarios_table))
expect_equal(unique(all_scenarios_table$scenario_name), list_out_scenarios(scenario_list)[check])
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.