Creating An Efficient Data Analysis Workflow, Part 2: SALES FROM PROGRAM


title: “objective is to identify whether new program was successful at increasing sales and improving review quality”
output: html_document

knitr::opts_chunk$set(echo = TRUE)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)

Including Plots

You can also embed plots, for example:

plot(pressure)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

sales <- read_csv(“sales2019.csv”)
sales
dim(sales)
colnames(sales)
typeof(colnames(sales))
is.na(sales)
sales <- sales > filter(!is.na(user_submitted_review))
sales
dim(sales)
##885 no of rows removed
average_purchased_book <- sales > filter(!is.na(total_purchased)) > pull(total_purchased) > mean
average_purchased_book
sales_1<- sales > mutate(total_purchased = if_else(is.na(total_purchased),average_purchased_book,total_purchased))
sales_1
unique(sales_1$user_submitted_review)
is_positive <- function(review) {
review_positive = case_when(
str_detect(review, “Awesome”) ~ TRUE,
str_detect(review, “OK”) ~ TRUE,
str_detect(review, “Never”) ~ TRUE,
str_detect(review, “a lot”) ~ TRUE,
TRUE ~ FALSE # The review did not contain any of the above phrases
)
}
sales_1 <- sales_1 > mutate(is_positive = unlist(map(user_submitted_review, is_positive)))
sales_1
library(lubridate)
standard_date <- mdy(sales_1$date)
sales_1 <- sales_1 > mutate (sales_pre_post_dates = if_else (standard_date < ymd(“2019/07/01”), “pre”, “post”))
sales_1 <- sales_1 > mutate (date = standard_date)
sales_1
summary_table <- sales_1 > group_by(sales_pre_post_dates) > summarize(purchased_values = sum(total_purchased))
summary_table

WE CAN SEE THAT THERE IS NO PROGRESS IN SALES POST PROGRAM

summary_table_2 <- sales_1 > group_by(customer_type,sales_pre_post_dates) > summarize(sales_values = sum(total_purchased))
summary_table_2

summary_table_3 <- sales_1 > group_by(sales_pre_post_dates) > summarize(compare_reviews = sum(is_positive, label = TRUE))
summary_table_3

WE CAN SEE THAT THERE IS IMPROVEMENT IN THE QUALITY OF REVIEW POST PROGRAM

CONCLUSION : Program has created slightly good quality reviews but failed in increasing the sales.

Hi @aradhyamath66:

Please refer to this guide for formatting your code and question link, which is not only for asking questions, but sharing ideas.

Thanks

2 Likes