Skip to content

Instantly share code, notes, and snippets.

@chipoglesby
Created April 27, 2015 15:48
Show Gist options
  • Save chipoglesby/de50b090794cb2603273 to your computer and use it in GitHub Desktop.
Save chipoglesby/de50b090794cb2603273 to your computer and use it in GitHub Desktop.
ad_id in R
ad_id <- data %>% group_by(CustomerID, Campaign, Adgroup, AdID) %>% summarize(
AverageCpc=round(sum(Cost) / sum(Clicks),2),
Clicks=sum(Clicks),
Impressions=sum(Impressions),
CTR=round(sum(Clicks) / sum(Impressions),2),
Cost=round(sum(Cost),2),
Conversions=sum(Conversions),
CPA=round(sum(Cost) / sum(Conversions),2),
ConversionRate=round(sum(Conversions) / sum(Clicks), 2))
ad_id[ad_id==Inf] <- 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment