Skip to content

Commit

Permalink
feat: filtering warning
Browse files Browse the repository at this point in the history
  • Loading branch information
laresbernardo committed May 28, 2024
1 parent a86c077 commit ff52474
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/robyn.R
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ plot.robyn_modelselector <- function(x, ...) {
robyn_performance <- function(
InputCollect, OutputCollect,
start_date = NULL, end_date = NULL,
solID = NULL, totals = TRUE, ...) {
solID = NULL, totals = TRUE, quiet = FALSE, ...) {
df <- OutputCollect$mediaVecCollect
if (!is.null(solID)) {
if (length(solID) > 1) {
Expand All @@ -457,6 +457,13 @@ robyn_performance <- function(
filter(.data$ds >= InputCollect$window_start, .data$ds <= InputCollect$window_end) %>%
filter(.data$solID == solID, .data$ds >= start_date, .data$ds <= end_date) %>%
select(c("ds", "solID", "type", InputCollect$all_media))
if (nrow(df) == 0 && !quiet) {
warning(sprintf(
"No data for model %s within modeling window (%s:%s) and date range filtered (%s:%s)",
solID, InputCollect$window_start, InputCollect$window_end,
start_date, end_date))
return(NULL)
}
spends <- df %>%
filter(.data$type == "rawSpend") %>%
summarise_if(is.numeric, function(x) sum(x, na.rm = TRUE))
Expand Down
3 changes: 3 additions & 0 deletions man/robyn_performance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff52474

Please sign in to comment.