Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. # 7QC_TOOL ----------------------------------------------------------------
  2. library(SixSigma)
  3. library(quicharts)
  4. library(plotrix)
  5. library(e1071) #ML
  6. # Fishbone ----------------------------------------------------------------
  7.  
  8.  
  9.  
  10. cManpower <- c("Recepcionist", "Record. Operator","Storage operators")
  11. cMaterials <- c("Supplier", "Transport agency","Packing")
  12. cMachines <- c("Compressor type","Operation conditions","Machine adjustment")
  13. cMethods <- c("Reception", "Transport method")
  14. cMeasurements <- c("Recording method","Measurement appraisal")
  15. cGroups <- c("Manpower", "Materials", "Machines","Methods", "Measurements")
  16. cEffect <- "Too high density"
  17. # detail data include
  18. cause.and.effect( cause = list(Manpower = cManpower,
  19. Materials = cMaterials,
  20. Machines = cMachines,
  21. Methods = cMethods,
  22. Measurements = cMeasurements),
  23. effect = cEffect)
  24.  
  25. library(SixSigma)
  26. library(e1071)
  27. ss.ceDiag(
  28. effect = cEffect,
  29. causes.gr <- cGroups,
  30. causes = list(cManpower, cMaterials, cMachines,
  31. cMethods, cMeasurements),
  32. main = "TOPIC",
  33. sub = "vice-topic")
  34.  
  35.  
  36. # Histogram ---------------------------------------------------------------
  37.  
  38. par(bg = "gray95")
  39. hist(robo_data,
  40. main = "TOPIC subject",
  41. sub = "vice-topic",
  42. xlab = expression("Rowname"),
  43. col = "steelblue",
  44. border = "white",
  45. lwd = 2,
  46. las = 1,
  47. bg = "gray")
  48.  
  49. ## other way to prove Lattice
  50.  
  51. library(lattice)
  52. histogram(robo_data,
  53. xlab = expression("RowName"),
  54. ylab = "Colnames",
  55. type = "density",
  56. panel = function(x, ...) {
  57. panel.histogram(x, ...)
  58. panel.mathdensity(dmath = dnorm,
  59. col = "black",
  60. lwd = 0.3,
  61. args = list(mean = mean(x),
  62. sd = sd(x)))
  63. } )
  64.  
  65.  
  66. # Pareto Chart ------------------------------------------------------------
  67.  
  68. ##80&20 rule told us : cause20%/ problem 80%
  69. data_checkSheet <- rbind(
  70. data.frame(Group = "Manpower",
  71. Cause = cManpower),
  72. data.frame(Group = "Machines",
  73. Cause = cMachines),
  74. data.frame(Group = "Materials",
  75. Cause = cMaterials),
  76. data.frame(Group = "Methods",
  77. Cause = cMethods),
  78. data.frame(Group = "Measurements",
  79. Cause = cMeasurements)
  80. )
  81.  
  82.  
  83. data_checkSheet$Factor_1 <- c(2, 0, 0, 2, 1, 7, 1, 3, 6, 0, 1, 2, 0)
  84. data_checkSheet$Factor_2 <- c(0, 0, 1, 1, 2, 1, 12, 1, 2, 1, 0, 0, 1)
  85. data_checkSheet$Factor_3 <- c(0, 1, 0, 6, 0, 2, 2, 4, 3, 0, 1, 0, 2)
  86. data_checkSheet$Total <- data_checkSheet$Factor_1 + data_checkSheet$Factor_2 +data_checkSheet$Factor_3
  87. data_checkSheet
  88.  
  89. barplot(height = data_checkSheet$Total,names.arg = data_checkSheet$Cause)
  90.  
  91. data_pareto <- data_checkSheet[order(data_checkSheet$Total,decreasing = TRUE), ]
  92. par(mar = c(8, 4, 4, 2) + 0.1)
  93.  
  94. barplot(height = data_pareto$Total,
  95. names.arg = data_pareto$Cause,
  96. las = 2,
  97. main = "Pareto chart for total causes")
  98. par(mar = c(8, 4, 4, 2) + 0.1)
  99.  
  100.  
  101. data_pareto2<- data_pareto$Total
  102. names(data_pareto2) <- data_pareto$Cause
  103. pareto.chart(data = data_pareto2,main = "Out-of-control causes")
  104.  
  105. #also can summary(pareto.chart)
  106.  
  107.  
  108. library(qualityTools)
  109. paretoChart(x = data_pareto2, main = "Out-of-control causes")
  110.  
  111. library(qicharts)
  112. spreadvector <- rep(names(data_pareto2),times = data_pareto2)
  113. paretochart(x=spreadvector)
  114.  
  115.  
  116.  
  117.  
  118.  
  119. # ScatterChart ------------------------------------------------------------
  120. set.seed(1234)
  121. robo_data2 <- 15*robo_data + rnorm(100)
  122.  
  123. plot(robo_data ~ robo_data2,
  124. col = "gray40", #which mean color of points
  125. pch = 20,
  126. main = "TOPIC",
  127. xlab = "RowName",
  128. ylab = expression("ColName"))
  129.  
  130. # Grantt & Shewhart.rules -------------------------------------------------
  131.  
  132.  
  133. head(cars)
  134. list(robo_data,robo_data2)
  135. shewhart.rules(ss1, limits = ss1$limits, run.length = qcc.options("run.length"))
  136. beyond.limits(cars, limits = cars$limits)
  137. violating.runs(cars, run.length = qcc.options("run.length"))
  138.  
  139. library(plotrix)
  140. require(plotrix)
  141. Ymd.format <- "%Y/%m/%d"
  142. gantt.info <- list(labels =
  143. c("First task"," Second task", "Third task",
  144. "Fourth task", "Fifth task"),
  145. starts = as.POSIXct(strptime(
  146. c("2012/01/01", "2012/02/02", "2012/03/03",
  147. "2012/05/05", "2012/09/09"),
  148. format = Ymd.format)),
  149. ends = as.POSIXct(strptime(
  150. c("2012/03/03", "2012/05/05", "2012/05/05",
  151. "2012/08/08", "2012/12/12"),
  152. format = Ymd.format)),
  153. priorities = c(1, 2, 3, 4, 5))
  154. vgridpos <- as.POSIXct(strptime(paste("2017/7/",(seq(1,12))),
  155. format = Ymd.format))
  156. vgridpos
  157.  
  158. vgridlab <- month.abb # All months
  159.  
  160. gantt.chart(gantt.info, main = "Topic subject",
  161. priority.legend = TRUE, vgridpos = vgridpos,
  162. vgridlab = vgridlab, hgrid = TRUE)
  163. ?gantt.chart
  164.  
  165.  
  166.  
  167.  
  168.  
  169. # Hypotthesis Testing -----------------------------------------------------
  170.  
  171. t.test(robo_data) #mean test
  172. var.test(robo_data,sample(1:10,10,replace = TRUE)) #var test
  173. prop.test() #Proportion test
  174.  
  175. ## Normality Test
  176. shapiro.test(robo_data)
  177. #QQplot Normality confirm by plot
  178. qqnorm(robo_data , pch = 16, col = gray(0.4))
  179. grid()
  180. qqline(robo_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement