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:

  1. Create Rmd file and read StoreData.csv into store.df
#1. Create Rmd file and read StoreData.csv into store.df
store.df <- read.csv(paste("StoreData.csv"), sep = ",")
  1. Output summary statistics (min, max, median etc) of the sales of Product 2 (Pepsi)
summary(store.df$p2sales)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    51.0    84.0    96.0   100.2   113.0   225.0
  1. Create a table aggregating the sales of Product 2 (Pepsi) in the presence / absence of promotions.
pepsisales <- data.frame("StoreNum"=store.df$storeNum, "Country" = store.df$country, "Pepsales" = store.df$p2sales, "Promotion"=store.df$p2prom )
cokesales <- data.frame("StoreNum"=store.df$storeNum, "Country" = store.df$country, "Coksales" = store.df$p1sales, "Promotion"=store.df$p1prom )
prom.pepsale <- subset(pepsisales, pepsisales$Promotion == 1)
noprom.pepsale <- subset(pepsisales, pepsisales$Promotion == 0)
prom.coksale <- subset(cokesales, cokesales$Promotion == 1)
noprom.coksale <- subset(cokesales, cokesales$Promotion == 0)
  1. Summary of Pepsi sales with promotion
summary(prom.pepsale)
##     StoreNum     Country    Pepsales       Promotion
##  Min.   :101.0   AU:12   Min.   : 70.0   Min.   :1  
##  1st Qu.:106.0   BR:35   1st Qu.:114.8   1st Qu.:1  
##  Median :110.0   CN:20   Median :132.0   Median :1  
##  Mean   :110.1   DE:79   Mean   :134.3   Mean   :1  
##  3rd Qu.:114.0   GB:40   3rd Qu.:151.2   3rd Qu.:1  
##  Max.   :120.0   JP:57   Max.   :225.0   Max.   :1  
##                  US:45
boxplot(prom.pepsale$Pepsales, xlab="Prod2Sale", ylab = "P2", main = "Sale of Pepsi with Promotion", horizontal = TRUE)

5.Summary of Pepsi sales without Promotion

summary(noprom.pepsale)
##     StoreNum     Country     Pepsales        Promotion
##  Min.   :101.0   AU: 92   Min.   : 51.00   Min.   :0  
##  1st Qu.:105.0   BR:173   1st Qu.: 81.00   1st Qu.:0  
##  Median :111.0   CN:188   Median : 92.50   Median :0  
##  Mean   :110.6   DE:441   Mean   : 94.68   Mean   :0  
##  3rd Qu.:116.0   GB:272   3rd Qu.:107.00   3rd Qu.:0  
##  Max.   :120.0   JP:359   Max.   :160.00   Max.   :0  
##                  US:267
boxplot(noprom.pepsale$Pepsales, xlab="Prod2Sale", ylab = "P2", main = "Sale of Pepsi without Promotion", horizontal = TRUE)

6.#Summary of Coke sales with Promotion

summary(prom.coksale)
##     StoreNum     Country    Coksales       Promotion
##  Min.   :101.0   AU:18   Min.   :106.0   Min.   :1  
##  1st Qu.:107.0   BR:25   1st Qu.:144.0   1st Qu.:1  
##  Median :112.0   CN:25   Median :167.0   Median :1  
##  Mean   :111.4   DE:50   Mean   :168.9   Mean   :1  
##  3rd Qu.:117.0   GB:22   3rd Qu.:192.2   3rd Qu.:1  
##  Max.   :120.0   JP:41   Max.   :263.0   Max.   :1  
##                  US:27
boxplot(prom.coksale$Coksales , xlab="Prod1Sale", ylab = "P1", main = "Sale of Pepsi without Promotion", horizontal = TRUE)

7.Summary of Coke sales without promotion

summary(noprom.coksale)
##     StoreNum     Country     Coksales       Promotion
##  Min.   :101.0   AU: 86   Min.   : 73.0   Min.   :0  
##  1st Qu.:105.0   BR:183   1st Qu.:111.0   1st Qu.:0  
##  Median :110.0   CN:183   Median :126.0   Median :0  
##  Mean   :110.4   DE:470   Mean   :129.1   Mean   :0  
##  3rd Qu.:115.0   GB:290   3rd Qu.:145.0   3rd Qu.:0  
##  Max.   :120.0   JP:375   Max.   :216.0   Max.   :0  
##                  US:285
boxplot(prom.coksale$Coksales , xlab="Prod1Sale", ylab = "P1", main = "Sale of Coke without Promotion", horizontal = TRUE)