This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
setwd("C:/Users/Navin/Documents/Murali/")
ncr <- read.csv2("NWTabLong.csv", header = TRUE,sep="," )
ncrO <- ncr[ncr$Type =="Original",]
# ncr$Client <- as.factor(ncr$Client)
library(ggplot2)
head(ncrO)
## Month Date Client Type Value
## 1 1 1/1/2013 1 Original 0.98
## 2 2 1/2/2013 1 Original 0.9807
## 3 3 1/3/2013 1 Original 0.9778
## 4 4 1/4/2013 1 Original 0.9781
## 5 5 1/5/2013 1 Original 0.9771
## 6 6 1/6/2013 1 Original 0.9867
ggplot(ncrO, aes(x = Value)) + geom_dotplot(dotsize = 0.8) + facet_grid(Client ~.)
ggplot(ncrO, aes(x = Value)) + geom_histogram(binwidth = 0.01)+ facet_grid(Client ~.)
ggplot(ncrO, aes(x = Value)) + geom_density()+ facet_grid(Client ~.)
ggplot(ncrO, aes(x = Value, y = Client)) + geom_point() + coord_flip()
ncr1 <- ncr[ncr$Client == 1,]
###
print("Client 1")
## [1] "Client 1"
ggplot(ncrO[ncrO$Client == 1,], aes(Month, Value)) + geom_line() + xlab("") + ylab("NW-Availability")
## geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
print("Client 2")
## [1] "Client 2"
ggplot(ncrO[ncrO$Client == 2,], aes(Month, Value)) + geom_line() + xlab("") + ylab("NW-Availability")
print("Client 3")
## [1] "Client 3"
ggplot(ncrO[ncrO$Client == 3,], aes(Month, Value)) + geom_line() + xlab("") + ylab("NW-Availability")
print("Client 4")
## [1] "Client 4"
ggplot(ncrO[ncrO$Client == 4,], aes(Month, Value)) + geom_line() + xlab("") + ylab("NW-Availability")
qplot(Month, Value, data = ncrO, colour = Client)
library(qcc)
## Package 'qcc', version 2.6
## Type 'citation("qcc")' for citing this R package in publications.
head(ncrO)
## Month Date Client Type Value
## 1 1 1/1/2013 1 Original 0.98
## 2 2 1/2/2013 1 Original 0.9807
## 3 3 1/3/2013 1 Original 0.9778
## 4 4 1/4/2013 1 Original 0.9781
## 5 5 1/5/2013 1 Original 0.9771
## 6 6 1/6/2013 1 Original 0.9867
x <- (ncrO[ncrO$Client == '1',])
x
## Month Date Client Type Value
## 1 1 1/1/2013 1 Original 0.98
## 2 2 1/2/2013 1 Original 0.9807
## 3 3 1/3/2013 1 Original 0.9778
## 4 4 1/4/2013 1 Original 0.9781
## 5 5 1/5/2013 1 Original 0.9771
## 6 6 1/6/2013 1 Original 0.9867
## 7 7 1/7/2013 1 Original 0.9873
## 8 8 1/8/2013 1 Original 0.9862
## 9 9 1/9/2013 1 Original 0.9849
## 10 10 1/10/2013 1 Original 0.9812
## 11 11 1/11/2013 1 Original 0.9855
## 12 12 1/12/2013 1 Original 0.9768
## 13 13 1/1/2014 1 Original 0.9788
## 14 14 1/2/2014 1 Original 0.9823
## 15 15 1/3/2014 1 Original 0.9825
## 16 16 1/4/2014 1 Original 0.9866
## 17 17 1/5/2014 1 Original 0.9838
## 18 18 1/6/2014 1 Original 0.9885
## 19 19 1/7/2014 1 Original 0.9877
## 20 20 1/8/2014 1 Original 0.9892
## 21 21 1/9/2014 1 Original 0.9916
## 22 22 1/10/2014 1 Original 0.9915
## 23 23 1/11/2014 1 Original 0.9898
## 24 24 1/12/2014 1 Original 0.9902
## 25 25 1/1/2015 1 Original 0.9862
## 26 26 1/2/2015 1 Original 0.9872
## 27 27 1/3/2015 1 Original 0.9875
## 28 28 1/4/2015 1 Original 0.9876
## 29 29 1/5/2015 1 Original 0.9875
## 30 30 1/6/2015 1 Original 0.9878
# my.xmr.raw <- c(5045,4350,4350,3975,4290,4430,4485,4285,3980,3925,3645,3760,3300,3685,3463,5200)
# ncrO1 <- ncrO[ncrO$Client == 1,][,5]
# qcc(ncrO1, type = "xbar.one", title = "Individuals Chart\nfor Wheeler sample data",ylab= "NWAvailability", xlab = "Months",digits = 4)
#
# as.vector(ncrO1)
#obj <- qcc((ncrO[ncrO$Client == 1,5]), type = "xbar.one", title = paste("Client", i),ylab= "NWAvailability", xlab = "Months",digits = 4)
#plot(obj, main = "Client1")
#process.capability(obj, spec.limits = c(0.95,0.999), digits = 3)
attach(ncr)
ncr1 <- ncr[Client==1,]
ncr2 <- ncr[Client==2,]
ncr3 <- ncr[Client==3,]
ncr4 <- ncr[Client==4,]
detach(ncr)
## For Client 1
# par(mfrow=c(2,2)
# par(mar=c(0.5, 4.5, 0.5, 0.5))
## Original
ncr1o <- ncr1[ncr1$Type == "Original",]
Fo <- ts(ncr1o[,5])
Fots <- ts(Fo, start = 2013, freq= 12)
hwFo <- HoltWinters(Fots)
plot(Fots,xlim=c(2013, 2016), ylab = "Original")
lines(predict(hwFo,n.ahead=18),col=2)
### Trend
ncr1t <- ncr1[ncr1$Type == "Trend",]
Ft <- ts(ncr1t[,5])
Ftts <- ts(Ft, start = 2013, freq= 12)
hwFt <- HoltWinters(Ftts)
plot(Ftts,xlim=c(2013, 2016), ylab = "Trend")
lines(predict(hwFt,n.ahead=18),col=2)
###Seasonal
ncr1s <- ncr1[ncr1$Type == "Seasonal",]
Fs <- ts(ncr1s[,5])
Fsts <- ts(Fs, start = 2013, freq= 12)
hwFs <- HoltWinters(Fsts)
plot(Fsts,xlim=c(2013, 2016),ylab = "Seasonal")
lines(predict(hwFs,n.ahead=18),col=2)
## Remainder
ncr1r <- ncr1[ncr1$Type == "Remainder",]
Fr <- ts(ncr1r[,5])
Frts <- ts(Fr, start = 2013, freq= 12)
hwFr <- HoltWinters(Frts)
plot(Frts,xlim=c(2013, 2016),ylab = "Remainder")
lines(predict(hwFr,n.ahead=18),col=2)
## For Client 2
#par(mfrow = c(2,2))
## Original
ncr2o <- ncr2[ncr2$Type == "Original",]
Fo <- ts(ncr2o[,5])
Fots <- ts(Fo, start = 2013, freq= 12)
hwFo <- HoltWinters(Fots)
plot(Fots,xlim=c(2013, 2016), ylab = "Original")
lines(predict(hwFo,n.ahead=18),col=2)
### Trend
ncr2t <- ncr2[ncr2$Type == "Trend",]
Ft <- ts(ncr2t[,5])
Ftts <- ts(Ft, start = 2013, freq= 12)
hwFt <- HoltWinters(Ftts)
plot(Ftts,xlim=c(2013, 2016), ylab = "Trend")
lines(predict(hwFt,n.ahead=18),col=2)
###Seasonal
ncr2s <- ncr2[ncr2$Type == "Seasonal",]
Fs <- ts(ncr2s[,5])
Fsts <- ts(Fs, start = 2013, freq= 12)
hwFs <- HoltWinters(Fsts)
## Warning in HoltWinters(Fsts): optimization difficulties: ERROR:
## ABNORMAL_TERMINATION_IN_LNSRCH
plot(Fsts,xlim=c(2013, 2016),ylab = "Seasonal")
lines(predict(hwFs,n.ahead=18),col=2)
## Remainder
ncr2r <- ncr2[ncr2$Type == "Remainder",]
Fr <- ts(ncr2r[,5])
Frts <- ts(Fr, start = 2013, freq= 12)
hwFr <- HoltWinters(Frts)
plot(Frts,xlim=c(2013, 2016),ylab = "Remainder")
lines(predict(hwFr,n.ahead=18),col=2)
## For Client 3
#par(mfrow = c(2,2))
## Original
ncr3o <- ncr3[ncr3$Type == "Original",]
ncr3o[,5]
## [1] 0.975 0.9577 0.9573 0.9327 0.9596 0.9523 0.9634 0.9646 0.975 0.9771
## [11] 0.924 0.8741 0.941 0.9364 0.9436 0.9453 0.9673 0.9669 0.9516 0.9624
## [21] 0.9726 0.9718 0.9644 0.9524 0.9379 0.9589 0.959 0.956 0.9424 0.9664
## 362 Levels: -0.00016 -0.00019 -0.00023 -0.00026 -0.00027 ... 0.9948
Fo <- ts(ncr3o[,5])
Fots <- ts(Fo, start = 2013, freq= 12)
hwFo <- HoltWinters(Fots)
plot(Fots,xlim=c(2013, 2016), ylab = "Original")
lines(predict(hwFo,n.ahead=18),col=2)
### Trend
ncr3t <- ncr3[ncr3$Type == "Trend",]
Ft <- ts(ncr3t[,5])
Ftts <- ts(Ft, start = 2013, freq= 12)
hwFt <- HoltWinters(Ftts)
plot(Ftts,xlim=c(2013, 2016), ylab = "Trend")
lines(predict(hwFt,n.ahead=18),col=2)
###Seasonal
ncr3s <- ncr3[ncr3$Type == "Seasonal",]
ncr3s
## Month Date Client Type Value
## 301 null 1/1/2013 3 Seasonal -0.00484
## 302 null 1/2/2013 3 Seasonal -0.00452
## 303 null 1/3/2013 3 Seasonal -0.0016
## 304 null 1/4/2013 3 Seasonal -0.00998
## 305 null 1/5/2013 3 Seasonal 0.00203
## 306 null 1/6/2013 3 Seasonal 0.00742
## 307 null 1/7/2013 3 Seasonal 0.00446
## 308 null 1/8/2013 3 Seasonal 0.01061
## 309 null 1/9/2013 3 Seasonal 0.02106
## 310 null 1/10/2013 3 Seasonal 0.02206
## 311 null 1/11/2013 3 Seasonal -0.00783
## 312 null 1/12/2013 3 Seasonal -0.03885
## 313 null 1/1/2014 3 Seasonal -0.00484
## 314 null 1/2/2014 3 Seasonal -0.00452
## 315 null 1/3/2014 3 Seasonal -0.0016
## 316 null 1/4/2014 3 Seasonal -0.00998
## 317 null 1/5/2014 3 Seasonal 0.00203
## 318 null 1/6/2014 3 Seasonal 0.00742
## 319 null 1/7/2014 3 Seasonal 0.00446
## 320 null 1/8/2014 3 Seasonal 0.01061
## 321 null 1/9/2014 3 Seasonal 0.02106
## 322 null 1/10/2014 3 Seasonal 0.02206
## 323 null 1/11/2014 3 Seasonal -0.00783
## 324 null 1/12/2014 3 Seasonal -0.03885
## 325 null 1/1/2015 3 Seasonal -0.00484
## 326 null 1/2/2015 3 Seasonal -0.00452
## 327 null 1/3/2015 3 Seasonal -0.0016
## 328 null 1/4/2015 3 Seasonal -0.00998
## 329 null 1/5/2015 3 Seasonal 0.00203
## 330 null 1/6/2015 3 Seasonal 0.00742
Fs <- ts(ncr3s[,5])
Fsts <- ts(Fs, start = 2013, freq= 12)
hwFs <- HoltWinters(Fsts)
## Warning in HoltWinters(Fsts): optimization difficulties: ERROR:
## ABNORMAL_TERMINATION_IN_LNSRCH
plot(Fsts,xlim=c(2013, 2016),ylab = "Seasonal")
lines(predict(hwFs,n.ahead=18),col=2)
## Remainder
ncr3r <- ncr3[ncr3$Type == "Remainder",]
Fr <- ts(ncr3r[,5])
Frts <- ts(Fr, start = 2013, freq= 12)
hwFr <- HoltWinters(Frts)
plot(Frts,xlim=c(2013, 2016),ylab = "Remainder")
lines(predict(hwFr,n.ahead=18),col=2)
## For Client 4
#par(mfrow = c(2,2))
## Original
ncr4o <- ncr4[ncr4$Type == "Original",]
Fo <- ts(ncr4o[,5])
Fots <- ts(Fo, start = 2013, freq= 12)
hwFo <- HoltWinters(Fots)
plot(Fots,xlim=c(2013, 2016), ylab ="Original" )
lines(predict(hwFo,n.ahead=18),col=2)
### Trend
ncr4t <- ncr4[ncr4$Type == "Trend",]
Ft <- ts(ncr4t[,5])
Ftts <- ts(Ft, start = 2013, freq= 12)
hwFt <- HoltWinters(Ftts)
plot(Ftts,xlim=c(2013, 2016), ylab = "Trend")
lines(predict(hwFt,n.ahead=18),col=2)
###Seasonal
ncr4s <- ncr4[ncr4$Type == "Seasonal",]
Fs <- ts(ncr4s[,5])
Fsts <- ts(Fs, start = 2013, freq= 12)
hwFs <- HoltWinters(Fsts)
## Warning in HoltWinters(Fsts): optimization difficulties: ERROR:
## ABNORMAL_TERMINATION_IN_LNSRCH
plot(Fsts,xlim=c(2013, 2016),ylab = "Seasonal")
lines(predict(hwFs,n.ahead=18),col=2)
## Remainder
ncr4r <- ncr4[ncr4$Type == "Remainder",]
Fr <- ts(ncr4r[,5])
Frts <- ts(Fr, start = 2013, freq= 12)
hwFr <- HoltWinters(Frts)
plot(Frts,xlim=c(2013, 2016),ylab = "Remainder")
lines(predict(hwFr,n.ahead=18),col=2)
####
kpi <- read.csv("kpi4.csv")
print("Correlation plot of various KPIs")
## [1] "Correlation plot of various KPIs"
kpiC <- kpi[,c(2,3,15:18)]
names(kpiC) <- gsub("..CLIENT1", "", names(kpiC))
# install.packages("corrplot")
library(corrplot)
M <- cor(kpiC)
corrplot(M, method = "circle")
#par(mfrow = c(1,1))
# getwd()
#
# install.packages("qcc")
library(qcc)
pare1 <- c(44,16,12,12,9,3,3,2)
names(pare1)<-c("HardFau","CashOut", "Comms", "DailyBalan","Host", "Vandalism","SuppliesOut","PM")
pareto.chart(pare1, ylab= "Hours", main = "Pareto Chart for Client A ( in hours)", col = "blue")
##
## Pareto chart analysis for pare1
## Frequency Cum.Freq. Percentage Cum.Percent.
## HardFau 44 44 43.564356 43.56436
## CashOut 16 60 15.841584 59.40594
## Comms 12 72 11.881188 71.28713
## DailyBalan 12 84 11.881188 83.16832
## Host 9 93 8.910891 92.07921
## Vandalism 3 96 2.970297 95.04950
## SuppliesOut 3 99 2.970297 98.01980
## PM 2 101 1.980198 100.00000
library(rCharts)
r1 <- rPlot(Value ~ Month | Client, data = ncrO, color = 'Client', type = 'point')
```
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.