#' Aggregate elasticity data
#'
#' @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 frame
#' @export
aggregate_elasticity_data_v1 = function(elasticityData, base_aggregation_on, aggregation_parameters){
if(!length(base_aggregation_on)==length(aggregation_parameters)){
stop("The length of 'base_aggregation_on' does not equal 'aggregation_parameters'")
}
print("Aggregating data...")
elasticityData = seperate_date_and_time(df=elasticityData, column_specifying_data = colnames(elasticityData)=="CON_DT")
col_to_coerse = c()
for(i in 1:ncol(elasticityData)){
if(class(elasticityData[,i])=="factor"){
col_to_coerse = c(col_to_coerse,i)
}
}
elasticityData = changeTypeOfColumns(df=elasticityData,rangeOfColumns = col_to_coerse, type = "character")
firstCol = colnames(elasticityData) == base_aggregation_on[1]
boolean_for_subset = elasticityData[,firstCol] == aggregation_parameters[1]
for(i in 1:length(base_aggregation_on)){
colIter = colnames(elasticityData) == base_aggregation_on[i]
boolean_for_subset = boolean_for_subset & elasticityData[colIter] == aggregation_parameters[i]
}
return(elasticityData[boolean_for_subset,])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.