#' Aggregate and summarize elasticity
#'
#' @param elasticityData A data frame.
#' @param base_aggregation_on A character vector specifying variables on which aggregation will be based.
#' @param aggregation_parameters A character vector specifying the variable variants on which aggregation will be based. Must be of length equal to the lenght of 'base_aggregation_on' and variable's variants must be in the order as variables. In this version only one variant of the variable can be supplied.
#' @return An aggregated data.
#' @export
aggregate_and_summarize_elasticity_by_date_v1 = function(elasticityData, base_aggregation_on, aggregation_parameters){
aggregated = aggregate_elasticity_data_v1(elasticityData=elasticityData,
base_aggregation_on=base_aggregation_on,
aggregation_parameters=aggregation_parameters)
print("Computing summaries per date...")
uniqueDates = unique(aggregated$date)
o = as.data.frame(matrix(nrow = 1,ncol = 7))
for(i in 1:length(uniqueDates)){
data_per_date = aggregated[aggregated$date==uniqueDates[i],]
Ns_per_date_sums = colSums(data_per_date[,12:15])
bookingCounts = nrow(data_per_date)
average_sell_price = mean(data_per_date$SELL_PRC)
addedUp_sell_price = sum(data_per_date$SELL_PRC)
rowPerBooking = c(Ns_per_date_sums,bookingCounts,average_sell_price,addedUp_sell_price)
o = rbind(o, rowPerBooking)
}
o = o[-1,]
row.names(o) = uniqueDates
colnames(o) = c("N_PAX","N_ADU","N_CHD","N_INF","bookingCounts", "average_sell_price", "addedUp_sell_price")
print("Done")
return(o)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.