Retail Analysis with walmart data

Discussion in 'Simplilearn Support' started by Kartikeya Tandon, Mar 19, 2020.

  1. Kartikeya Tandon

    Joined:
    Jan 6, 2020
    Messages:
    2
    Likes Received:
    0
    • Which store has a maximum standard deviation i.e., the sales vary a lot. Also, find out the coefficient of mean to standard deviation
    • Which store/s has a good quarterly growth rate in Q3’2012
    • Provide a monthly and semester view of sales in units and give insights
     

    Attached Files:

    • my.txt
      File size:
      2 KB
      Views:
      4
    #1
  2. Kunal Guwalani

    Kunal Guwalani Well-Known Member
    Simplilearn Support

    Joined:
    Jul 17, 2018
    Messages:
    190
    Likes Received:
    19
    Please refer to the code below:

    ###Which store has maximum standard deviation i.e the sales vary a lot.
    ######### Also find out coefficient of mean to standard deviation
    Stores_with_mean= aggregate(Weekly_Sales~Store,walmartretail,mean)
    library(plyr)
    Stores_with_mean = rename(Stores_with_mean,c(Weekly_Sales="Mean_Sales"))
    View(Stores_with_mean)

    Stores_with_std= aggregate(Weekly_Sales~Store,walmartretail,sd)
    Stores_with_std = rename(Stores_with_std,c(Weekly_Sales="Sd_Sales"))
    View(Stores_with_std)

    Stores_with_std_mean = cbind(Stores_with_mean,Stores_with_std)
    View(Stores_with_std_mean)

    Stores_with_std_mean_coeff = transform(Stores_with_std_mean,Coeff=(Sd_Sales/Mean_Sales))
    View(Stores_with_std_mean_coeff)

    #### Which store/s has good quarterly growth rate in Q3’2012
    Stores_with_Q_Flag = transform(walmartretail,Q_Flag= ifelse((Date>='2012-04-01' & Date<= '2012-06-30'),"Q2_2012",
    ifelse((Date>='2012-07-01' & Date<= '2012-09-30'),"Q3_2012","-")))

    # confirming start and end date for each quarter
    aggregate(Date ~ Q_Flag, Stores_with_Q_Flag, min)
    aggregate(Date ~ Q_Flag, Stores_with_Q_Flag, max)


    # summarizing and then reshaping
    Stores_with_Q_Flag_sum = aggregate(Weekly_Sales~Store+Q_Flag,Stores_with_Q_Flag,sum)
    View(Stores_with_Q_Flag_sum)
    str(Stores_with_Q_Flag_sum)

    Stores_with_Q_Flag_sum_t = reshape(Stores_with_Q_Flag_sum,idvar="Store",timevar ='Q_Flag',direction="wide")
    View(Stores_with_Q_Flag_sum_t)
    Stores_with_Q_Flag_sum_t_GR = transform(Stores_with_Q_Flag_sum_t,
    GR=((Weekly_Sales.Q3_2012-Weekly_Sales.Q2_2012)/Weekly_Sales.Q2_2012))
    View(Stores_with_Q_Flag_sum_t_GR)
     
    #2

Share This Page