Staffing Business Case study:

Data Generation process:

# Date start = Monday 25th week of 2017
# Each day has two observations( 1,2)  = (am, pm)
# Each week 10 observations; mon-fri

Packages to be used

      library(pacman)
        pacman::p_load(forecast)
        p_load(tidyverse, lubridate, rio, pdfetch, tidyverse, readxl,dygraphs)
        library(dygraphs)
        
                # Secondary packages        
                pacman::p_load(tsibble, fable)
                pacman::p_load(tsibbledata)
                pacman::p_load(feasts, fpp3)
                library(ggthemes)
                library(tsbox) #convert xts to tsibble
                library(TSstudio)
                library(xts)
                library(zoo)
                library(ggthemes)

Import and preview data

dr1 = import("staffing.csv")
 head(dr1) 
##   V1  V2
## 1  1 203
## 2  2 243
## 3  3 146
## 4  4 204
## 5  5 167
## 6  6 197
 str(dr1) # note that this is an indexed vector not a time series
## 'data.frame':    144 obs. of  2 variables:
##  $ V1: int  1 2 3 4 5 6 7 8 9 10 ...
##  $ V2: int  203 243 146 204 167 197 174 201 209 589 ...

Convert Indexed vector to time-series variable

# We are picking only the staffing volumes to analyze the patterns in the data.
# we are generating the date twice in a day from mon-fri, so the frequency is 10 for a week

mycounts = ts(dr1[2], start = c(1,1), frequency = 10)

Understand the nature of the data

str(mycounts)
##  Time-Series [1:144, 1] from 1 to 15.3: 203 243 146 204 167 197 174 201 209 589 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr "V2"
head(mycounts)
## Time Series:
## Start = c(1, 1) 
## End = c(1, 6) 
## Frequency = 10 
##       V2
## [1,] 203
## [2,] 243
## [3,] 146
## [4,] 204
## [5,] 167
## [6,] 197
time(mycounts)
## Time Series:
## Start = c(1, 1) 
## End = c(15, 4) 
## Frequency = 10 
##   [1]  1.0  1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.0  2.1  2.2  2.3  2.4
##  [16]  2.5  2.6  2.7  2.8  2.9  3.0  3.1  3.2  3.3  3.4  3.5  3.6  3.7  3.8  3.9
##  [31]  4.0  4.1  4.2  4.3  4.4  4.5  4.6  4.7  4.8  4.9  5.0  5.1  5.2  5.3  5.4
##  [46]  5.5  5.6  5.7  5.8  5.9  6.0  6.1  6.2  6.3  6.4  6.5  6.6  6.7  6.8  6.9
##  [61]  7.0  7.1  7.2  7.3  7.4  7.5  7.6  7.7  7.8  7.9  8.0  8.1  8.2  8.3  8.4
##  [76]  8.5  8.6  8.7  8.8  8.9  9.0  9.1  9.2  9.3  9.4  9.5  9.6  9.7  9.8  9.9
##  [91] 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4
## [106] 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9
## [121] 13.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4
## [136] 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3
cycle(mycounts)
## Time Series:
## Start = c(1, 1) 
## End = c(15, 4) 
## Frequency = 10 
##   [1]  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5
##  [26]  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10
##  [51]  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5
##  [76]  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10
## [101]  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5
## [126]  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4
frequency(mycounts)
## [1] 10
plot(mycounts)

#These commands helps us to understand how data is generated and their frequency
#More importantly, how cycle is defined in the dataset.
#high-level understanding of patterns using plot function.

Visualize the data:

labs = c( "Mam", "Mpm", "Tam", "Tpm", "Wam", "Wpm", "Tham", "Thpm", "Fam", "Fpm")
                monthplot(mycounts, main = "Staffing", labels = labs, xlab = "Bidaily Units")

ggsubseriesplot(mycounts, main = "Staffing" , labels = labs)

Conclusion:

Recommendations: