#' Prepare figures for small exercises about the high-low method of cost estimation.
#' @param vol Numeric. Volume of activity.
#' @param uvcs Numeric vector. Unit Variable Costs for each account.
#' @param varprops Numeric vector. Percentage of each account which is variable.
#' @return A list with the base for the computation, the solution, the wrong_uvc and the wrong_fc for MCQ.
#' @export
ce_accountanalysis <- function(vol = 1000, uvcs = c(3,2), varprops = c(0.6,0.4)){
volume <- NULL
base <- data.frame(
volume = vol,
variable_costs = vol * uvcs,
variable_prop = varprops
)
base$total_costs <- base$variable_costs / varprops
base$fixed_costs <- base$total_costs - base$variable_costs
base <- base[,c("volume", "variable_prop", "variable_costs", "fixed_costs", "total_costs")]
base <- as.data.frame(apply(base, 2, round, digits = 2))
solution <- list(
volume = vol,
variable = sum(base$variable_costs),
fixed = sum(base$fixed_costs),
uvc = sum(uvcs),
fc = sum(base$fixed_costs)
)
prep_wrong <- base
prep_wrong$wrong_vc1 <- prep_wrong$fixed_costs * prep_wrong$variable_prop
prep_wrong$wrong_tc <- prep_wrong$fixed_costs / prep_wrong$variable_prop
prep_wrong$wrong_tc <- prep_wrong$wrong_tc - prep_wrong$fixed_costs
wrong_uvc <- c(
wuvc1 = round(solution$fc / volume,2),
wuvc2 = round(sum(base$total_costs) / volume,2),
wuvc3 = round(sample(base$variable_costs,1) / volume,2),
wuvc4 = round(sample(base$fixed_costs,1) / volume,2),
wuvc5 = round(sum(prep_wrong$wrong_vc1) / volume,2),
wuvc6 = round(sum(prep_wrong$wrong_vc2) / volume,2),
wuvc7 = 0,
wuvc8 = round(sample(c(0.75,0.8,0.85,0.9),1)*solution$uvc,2),
wuvc9 = round(sample(c(1.1,1.15,1.2),1)*solution$uvc,2)
)
wrong_uvc <- unique(setdiff(wrong_uvc, solution$uvc))
wrong_fc <- c(
wfc1 = round(sum(prep_wrong$total_costs - vol * wrong_uvc[[1]]),2),
wfc2 = round(sum(prep_wrong$total_costs - vol * wrong_uvc[[2]]),2),
wfc3 = round(sum(prep_wrong$total_costs - vol * wrong_uvc[[3]]),2),
wfc4 = round(sum(prep_wrong$total_costs - vol * wrong_uvc[[4]]),2),
wfc5 = round(sum(base$variable_costs),2),
wfc6 = round(sum(base$total_costs),2),
wfc7 = 0,
wfc8 = round(sample(c(0.75,0.8,0.85,0.9),1)*solution$fc,2),
wfc9 = round(sample(c(1.1,1.15,1.2),1)*solution$fc,2)
)
wrong_fc <- unique(setdiff(wrong_fc, solution$fc))
output <- list(
base = base,
solution = solution,
wrong_uvc = wrong_uvc,
wrong_fc = wrong_fc
)
return(output)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.