Important before geting started

1. Set working directory

2. Read the data StoreData.csv file into a data frame called store.df.

QUESTION 1

Q1a. Write R code to show the total number of rows and columns present in the data frame store.df.

Q1b. Write R code to list the names of the column present in the data frame store.df.

QUESTION 2

Q2a. Write R code to output the data types of the different columns.

Q2b. Write R code to convert the data types of the columns {Year, p1prom, p2prom, country} into factor variables.

Q2c. Write R code to verify the conversions done in Q2b.

QUESTION 3

Q3a. Write R code to generate the summary statistics of the different variables present in the data frame store.df.

Bonus: Q3b. Write R code to generate the following table using the describe() function from the psych package in R.

##          vars    n   mean    sd median trimmed   mad    min   se
## storeNum    1 2080 110.50  5.77 110.50  110.50  7.41 101.00 0.13
## Year        2 2080   1.50  0.50   1.50    1.50  0.74   1.00 0.01
## Week        3 2080  26.50 15.01  26.50   26.50 19.27   1.00 0.33
## p1sales     4 2080 133.05 28.37 129.00  131.08 26.69  73.00 0.62
## p2sales     5 2080 100.16 24.42  96.00   98.05 22.24  51.00 0.54
## p1price     6 2080   2.54  0.29   2.49    2.53  0.44   2.19 0.01
## p2price     7 2080   2.70  0.33   2.59    2.69  0.44   2.29 0.01
## p1prom      8 2080   0.10  0.30   0.00    0.00  0.00   0.00 0.01
## p2prom      9 2080   0.14  0.35   0.00    0.05  0.00   0.00 0.01
## country*   10 2080   4.55  1.72   4.50    4.62  2.22   1.00 0.04

QUESTION 4

Q4a. Break-up store.df by country. Write R code to generate the following break-ups by country.

## country
##  AU  BR  CN  DE  GB  JP  US 
## 104 208 208 520 312 416 312

Q4b. Write R code to express Q4a numbers in terms of percentages.

QUESTION 5

Q5a.The dataset has 2080 rows of weekly data for 20 unique store branches for two different years. For product 1 (Coke) and product 2 (Pepsi), write R code to count the number of weeks,

  1. When both products were under promotion?

  2. When product 1 (Coke) was under promotion but product 2 (Pepsi) was not under promotion?

  3. When product 1 (Coke) was not under promotion but product 2 (Pepsi) was under promotion?

  4. When neither product was under promotion?

Q5b. Express Q5a as in percentages.

Q5c. Write R code to calculate the average price of product 1 (Coke) and product 2 (Pepsi) when both were under promotion.

Q5d. Write R code to calculate the average price of product 1 (Coke) and product 2 (Pepsi) when neither of them was under promotion.

Q5e. Write R code to calculate the average price of product 1 (Coke) and product 2 (Pepsi) when only one of them was under promotion.

QUESTION 6

Q6. Analyze the above numbers. Think like a Senior Manager. Prepare a list of qualitative insights on the “Effect of Promotions on Sales” of Coke and Pepsi, to be shared in class.