Project #1 (Walmart Data) Question for R programming

Discussion in 'Simplilearn Support' started by Amrutha Vutpala, Sep 25, 2020.

  1. Amrutha Vutpala

    Alumni

    Joined:
    Aug 13, 2020
    Messages:
    2
    Likes Received:
    0
    Im not sure where i am supposed to post my queries but i need help on the Project #1 Walmart Data in R programming. I am stuck on question#3 "Which store/s has good quarterly growth rate in Q3’2012" and not sure how to get started with this question. I noticed that the Date is a Character rather than a numeric(date) so i tried to transform the Character into Date format but i am getting a bunch of NAs in the output. Please help!
     
    #1
  2. Hitesh H S

    Hitesh H S Well-Known Member
    Staff Member Simplilearn Support

    Joined:
    May 27, 2020
    Messages:
    122
    Likes Received:
    27
    Hi Amrutha,

    I would request you to kindly refer to the recordings once again before working on your project. However,
    you can use the following code for your reference. You need to convert it into a date format. Please find the below code for your reference.

    library(dplyr)
    install.packages('lubridate')
    # changing date format
    library(lubridate)
    mart$Date <- dmy(mart$Date)

    mart <- mart %>% mutate(Year=year(Date),Quarter=quarter(Date))
    View(mart)
    mart <- mart %>% mutate(Qt=paste(Year,'Q',Quarter, sep = ''))
    View(mart)
    coeff2 <- mart %>% group_by(Store,Qt) %>% summarise(Quarter_sales=sum(Weekly_Sales))
    coeff2
    coeff2 <- coeff2 %>% mutate(Lagsales=lag(Quarter_sales,4))
    coeff2
    coeff2 <- coeff2 %>% mutate(Comparison=(Quarter_sales/Lagsales)*100) %>% arrange(desc(Comparison))
    coeff2
    coeff2 <- coeff2 %>% filter(Qt=='2012Q3') %>% mutate(Comparison=(Quarter_sales/Lagsales)*100) %>% arrange(desc(Comparison))
    coeff2

    I hope this helps you.

    Happy Learning !!!
     
    #2

Share This Page