Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is my cleaned R data for the Completejourney data set ```{r} install.packages(tidyverse) install.packages('completejourney') library(tidyverse) library(completejourney) install.packages(naniar) library(naniar) library(lubridate) ``` ```{r} promotions % filter(campaign_type !=

Below is my cleaned R data for the Completejourney data set

```{r} install.packages("tidyverse") install.packages('completejourney') library(tidyverse) library(completejourney) install.packages("naniar") library(naniar) library(lubridate) ```

```{r} promotions <- get_promotions() transactions <- get_transactions() ```

''' This section combines campaign and coupon data Campaign type "A" can be analyzed by demographics because not the same coupons were sent to everyone

campaign_details_BC: is information on all campaigns that are not Type "A" or NA (added campaign length to file)

coupon_details: is all coupon information (coupons & coupon_redemption tables) (added year and month for graphing)

campaign_redemptions: is combine coupon and campaign details for all coupons that were used (campaigns (B&C) ONLY)

campaign_dates: is just created for an inner join to do the calculation on total coupons used/life of campaign campaign_totals: is just created to be mutated for total coupons used/ life of campaign and is then mutated to separate the day number and force it to be a number

''' ```{r} campaign_details_BC <- campaigns %>% left_join(campaign_descriptions) %>% filter(campaign_type != "Type A" & !is.na(campaign_type)) campaign_details_BC <- mutate(campaign_details_BC, campaign_length = end_date - start_date) coupon_details <- coupons %>% left_join(coupon_redemptions) coupon_details <- mutate(coupon_details, redemption_year = year(redemption_date), redemption_month = month(redemption_date)) ```

```{r} campaign_redemptions <- campaign_details_BC %>% inner_join(coupon_details) %>% distinct() campaign_dates <- campaign_redemptions %>% distinct(campaign_id,campaign_length) ```

''' Total Coupons used by campaign (top 10 campaigns) '''

```{r} campaign_totals_used <- campaign_redemptions %>% group_by(campaign_id) %>% count(household_id) %>% arrange(desc(n)) %>% inner_join(campaign_dates, by = 'campaign_id') campaign_totals_used <- separate(campaign_totals_used,campaign_length, into = c('days', 'unit'), sep = ' ')

campaign_totals_used$days <- as.integer(campaign_totals_used$days) campaign_totals_used$daily_avg <- with(campaign_totals_used,n/days)

top_10_campaigns_qauntity <- head(campaign_totals_used %>% arrange(desc(daily_avg)), n = 10) ```

''' Need sales info so have to join with transactions Combining campaign redemptions with transactions

I added the inner_join to top 10 campaigns to look at top sales of products (quantity and sales_value)

'''

```{r} top_10_products_total_sales <- head(campaign_redemptions %>% inner_join(top_10_campaigns_qauntity) %>% inner_join((transactions)) %>% group_by(product_id)%>% summarize(total_sales = sum(sales_value)) %>% arrange(desc(total_sales)), n = 10)

top_10_products_quantity <- head(campaign_redemptions %>% inner_join(top_10_campaigns_qauntity) %>% inner_join((transactions)) %>% group_by(product_id)%>% summarize(total_quantity = sum(quantity)) %>% arrange(desc(total_quantity)), n = 10)

```

''' Finally, I am joining the top 10 products (by sales and quantity) to promotions so we can see the top display locations and mailer locations '''

```{r} top_10_promotions_step1 <- campaign_redemptions %>% inner_join(top_10_campaigns_qauntity) %>% inner_join(transactions) top_10_promotions_step1 <- mutate(top_10_promotions_step1,week = week(transaction_timestamp)) top_10_promotions_step1 %>% inner_join(promotions)

I need help answering the below 3 questions by graphing them out.

1.what campaigns are best from a coupon usage standpoint and total sales standpoint (Show one graph that answers the question)

2.what makes a campaign good (successful display locations and successful mailer location)(Show one graph that answers the question)

3. What campaigns are most successful with certain demo groupsShow one graph that answers the question)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Calculus Early Transcendentals

Authors: Jon Rogawski, Colin Adams, Robert Franzosa

4th Edition

1319055907, 9781319055905

More Books

Students also viewed these Mathematics questions