@@ -108,7 +108,6 @@ robyn_allocator <- function(robyn_object = NULL,
108108 quiet = FALSE ,
109109 ui = FALSE ,
110110 ... ) {
111-
112111 # ## Use previously exported model using json_file
113112 if (! is.null(json_file )) {
114113 if (is.null(InputCollect )) {
@@ -141,12 +140,12 @@ robyn_allocator <- function(robyn_object = NULL,
141140 # OutputCollect <- imported$OutputCollect
142141 # select_model <- imported$select_model
143142 # } else {
144- if (is.null(select_model ) && length(OutputCollect $ allSolutions == 1 )) {
145- select_model <- OutputCollect $ allSolutions
146- }
147- if (any(is.null(InputCollect ), is.null(OutputCollect ), is.null(select_model ))) {
148- stop(" When 'robyn_object' is not provided, then InputCollect, OutputCollect, select_model must be provided" )
149- }
143+ if (is.null(select_model ) && length(OutputCollect $ allSolutions == 1 )) {
144+ select_model <- OutputCollect $ allSolutions
145+ }
146+ if (any(is.null(InputCollect ), is.null(OutputCollect ), is.null(select_model ))) {
147+ stop(" When 'robyn_object' is not provided, then InputCollect, OutputCollect, select_model must be provided" )
148+ }
150149 # }
151150
152151 if (length(InputCollect $ paid_media_spends ) < = 1 ) {
@@ -238,9 +237,12 @@ robyn_allocator <- function(robyn_object = NULL,
238237 simulation_period <- initial_mean_period <- unlist(summarise_all(select(histFiltered , any_of(mediaSpendSorted )), length ))
239238 nDates <- lapply(mediaSpendSorted , function (x ) histFiltered $ ds )
240239 names(nDates ) <- mediaSpendSorted
241- if (! quiet ) message(sprintf(
242- " Date Window: %s:%s (%s %ss)" ,
243- date_min , date_max , unique(initial_mean_period ), InputCollect $ intervalType ))
240+ if (! quiet ) {
241+ message(sprintf(
242+ " Date Window: %s:%s (%s %ss)" ,
243+ date_min , date_max , unique(initial_mean_period ), InputCollect $ intervalType
244+ ))
245+ }
244246 zero_spend_channel <- names(histSpendWindow [histSpendWindow == 0 ])
245247
246248 initSpendUnitTotal <- sum(initSpendUnit )
@@ -359,14 +361,19 @@ robyn_allocator <- function(robyn_object = NULL,
359361 skip_these <- (channel_constr_low == 0 & channel_constr_up == 0 )
360362 zero_constraint_channel <- mediaSpendSorted [skip_these ]
361363 if (any(skip_these ) && ! quiet ) {
362- message(" Excluded variables (constrained to 0): " ,
363- paste(zero_constraint_channel , collapse = " , " ))
364+ message(
365+ " Excluded variables (constrained to 0): " ,
366+ paste(zero_constraint_channel , collapse = " , " )
367+ )
364368 }
365369 if (! all(coefSelectorSorted )) {
366370 zero_coef_channel <- setdiff(names(coefSelectorSorted ), mediaSpendSorted [coefSelectorSorted ])
367- if (! quiet ) message(
368- " Excluded variables (coefficients are 0): " ,
369- paste(zero_coef_channel , collapse = " , " ))
371+ if (! quiet ) {
372+ message(
373+ " Excluded variables (coefficients are 0): " ,
374+ paste(zero_coef_channel , collapse = " , " )
375+ )
376+ }
370377 } else {
371378 zero_coef_channel <- as.character()
372379 }
@@ -754,7 +761,9 @@ robyn_allocator <- function(robyn_object = NULL,
754761 select_model , scenario , eval_list ,
755762 export , plot_folder , quiet
756763 )
757- } else plots <- NULL
764+ } else {
765+ plots <- NULL
766+ }
758767
759768 output <- list (
760769 dt_optimOut = dt_optimOut ,
0 commit comments