From 46fee50eff5576ec8087110438a6a27f82bfa6a0 Mon Sep 17 00:00:00 2001 From: Chris Salvato Date: Wed, 25 May 2016 18:44:31 -0400 Subject: [PATCH] Move Bing specific formatting of data out of mixpanel utilities function. These should be decoupled. --- BingUtilities/R/keyword_performance_data.r | 2 +- MixpanelUtilities/R/clean_completed_order_events.r | 4 ---- PowerSupplyUtilities/R/create_bing_event_log.r | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BingUtilities/R/keyword_performance_data.r b/BingUtilities/R/keyword_performance_data.r index bc7cbdb..b6a0f3b 100644 --- a/BingUtilities/R/keyword_performance_data.r +++ b/BingUtilities/R/keyword_performance_data.r @@ -14,7 +14,7 @@ #' @examples #' keyword_performance_data(from=20151216, to=20151219) keyword_performance_data <- function(from=Sys.Date(), to=Sys.Date()) { - raw <- raw_keyword_performance_data(from, to) + raw <- BingUtilities::raw_keyword_performance_data(from, to) cleaned <- BingUtilities::clean_raw_keyword_data(raw) return(cleaned) } \ No newline at end of file diff --git a/MixpanelUtilities/R/clean_completed_order_events.r b/MixpanelUtilities/R/clean_completed_order_events.r index 3b3f7af..77e43b2 100644 --- a/MixpanelUtilities/R/clean_completed_order_events.r +++ b/MixpanelUtilities/R/clean_completed_order_events.r @@ -11,9 +11,5 @@ clean_completed_order_events <- function(events_matrix){ events_data_frame <- events_data_frame %>% rename(app_user_id = id) events_data_frame <- events_data_frame %>% mutate(app_user_id = as.numeric(as.character(app_user_id))) - #Clean up keywords info for future lookup of Keyword name with Keyword ID from Bing data. - events_data_frame <- events_data_frame %>% mutate(keyword_id = as.numeric(gsub("kwd-","",latest_ad_awkeyword))) - events_data_frame <- events_data_frame %>% select( -latest_ad_awkeyword ) - return(events_data_frame) } \ No newline at end of file diff --git a/PowerSupplyUtilities/R/create_bing_event_log.r b/PowerSupplyUtilities/R/create_bing_event_log.r index 999fe60..450346d 100644 --- a/PowerSupplyUtilities/R/create_bing_event_log.r +++ b/PowerSupplyUtilities/R/create_bing_event_log.r @@ -21,6 +21,10 @@ create_bing_event_log <- function(from=Sys.Date(), ppc_events <- all_ppc_raw_completed_order_events( from = from, to = to ) mixpanel_bing_conversions <- ppc_events[["bing"]] mixpanel_bing_conversions <- clean_completed_order_events(mixpanel_bing_conversions) + #Clean up keywords info for future lookup of Keyword name with Keyword ID from Bing data. + mixpanel_bing_conversions <- mixpanel_bing_conversions %>% + mutate(keyword_id = as.numeric(gsub("kwd-","",latest_ad_awkeyword))) %>% + select(-latest_ad_awkeyword) ##### Retrieve Bing Spend/Click Data bing_keywords_data <- BingUtilities::keyword_performance_data(from=as.Date(from), to=as.Date(to))