setwd('/Users/shikharkohli/code/DAM')
Storedata.df <- read.csv('datasets/StoreData.csv')
View(Storedata.df)
## ------------------------------------------------------------------------
summary(Storedata.df$p2sales)   # Summary of Product 2 Sales Data using summary() command
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    51.0    84.0    96.0   100.2   113.0   225.0
## ------------------------------------------------------------------------
attach(Storedata.df)            # Attaching the StoreData set before boxplot command
boxplot(p2sales,data=Storedata.df,  # Boxplot Command for Product 2 Sales
        main="Box Plot", 
        ylab="Sales of Product 2 (Pepsi)")

## ------------------------------------------------------------------------

subset of Product 2 Sales with promotion and without promotion

without_prom = subset(Storedata.df, p2prom == 0)   # Without promotion for product p2
with_prom    = subset(Storedata.df, p2prom == 1)   # With promotion for product p2
View(without_prom)
View(with_prom)

Aggregating the Products 2 Sales with or without promotion for the Product 2 (Pepsi)

sum(without_prom$p2sales)   # aggregate of Product 2 sales when promotion is not done
## [1] 169659
sum(with_prom$p2sales)      # aggregate of Product 2 sales when promotion is done
## [1] 38667
## ------------------------------------------------------------------------

attach(Storedata.df)
## The following objects are masked from Storedata.df (pos = 3):
## 
##     Week, Year, country, p1price, p1prom, p1sales, p2price,
##     p2prom, p2sales, storeNum
Storedata.df$p2prom.f <- factor(Storedata.df$p2prom, levels=c(0,1),    labels=c("No","Yes"))

boxplot(p2sales~p2prom.f, data=Storedata.df, main = "Weekly sales of Pepsi with and without promotion", xlabs="Weekly Sales", ylabs="Pepsi Promoted in Store", horizontal = TRUE )

Averaging the sales of Product 2 with or without promotion

library (gplots)
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
plotmeans(Storedata.df$p2sales~Storedata.df$p2prom.f, data=Storedata.df)
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped

## ------------------------------------------------------------------------