Advertisement
cbattles516

Capabilities

Sep 25th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 40.90 KB | None | 0 0
  1. # Function to generate text and graphical capabilities analyses on a data set
  2. # (c) 2014 Christopher Battles
  3.  
  4. vectis.cap <- function(data,
  5.                        distribution = "normal",
  6.                        USL = NA,
  7.                        LSL = NA,
  8.                        target = NA,
  9.                        main = "Process Capability",
  10.                        sub = "",
  11.                        groupsize = 1,
  12.                        mrlength = 2,
  13.                        alpha = 0.05,
  14.                        tol = 6,
  15.                        unbias_sub = TRUE,
  16.                        unbias_overall = FALSE,
  17.                        density = FALSE,
  18.                        binwidth = -1,
  19.                        plot = TRUE,
  20.                        name = "Measurement",
  21.                        footer = TRUE
  22.                        )
  23. {
  24.  
  25.   library(ggplot2)
  26.   library(grid)
  27.   library(gtable)
  28.   library(nortest)
  29.  
  30.   if (is.na(target)){
  31.   stop("Target not specified")
  32.   }
  33.   if (is.na(LSL) && is.na(USL)){
  34.   stop("Upper and Lower Specification Limits not specified")
  35.   }
  36.   if (groupsize < 1 || groupsize > 50){
  37.   stop("Group Size must be between 1 and 50")
  38.   }
  39.   if (mrlength < 2){
  40.   stop("Moving Range Length must be greater than or equal to 2")
  41.   }
  42.  
  43.   Lookup <-
  44.     {structure(list(N = 1:100,
  45.                    c4 = c(NA, 0.797885, 0.886227, 0.921318,
  46.                           0.939986, 0.951533, 0.959369, 0.96503, 0.969311, 0.972659, 0.97535,
  47.                           0.977559, 0.979406, 0.980971, 0.982316, 0.983484, 0.984506, 0.98541,
  48.                           0.986214, 0.986934, 0.987583, 0.98817, 0.988705, 0.989193, 0.98964,
  49.                           0.990052, 0.990433, 0.990786, 0.991113, 0.991418, 0.991703, 0.991969,
  50.                           0.992219, 0.992454, 0.992675, 0.992884, 0.99308, 0.993267, 0.993443,
  51.                           0.993611, 0.99377, 0.993922, 0.994066, 0.994203, 0.994335, 0.99446,
  52.                           0.99458, 0.994695, 0.994806, 0.994911, 0.995013, 0.99511, 0.995204,
  53.                           0.995294, 0.995381, 0.995465, 0.995546, 0.995624, 0.995699, 0.995772,
  54.                           0.995842, 0.99591, 0.995976, 0.99604, 0.996102, 0.996161, 0.996219,
  55.                           0.996276, 0.99633, 0.996383, 0.996435, 0.996485, 0.996534, 0.996581,
  56.                           0.996627, 0.996672, 0.996716, 0.996759, 0.9968, 0.996841, 0.99688,
  57.                           0.996918, 0.996956, 0.996993, 0.997028, 0.997063, 0.997097, 0.997131,
  58.                           0.997163, 0.997195, 0.997226, 0.997257, 0.997286, 0.997315, 0.997344,
  59.                           0.997372, 0.997399, 0.997426, 0.997452, 0.997478),
  60.                    c5 = c(NA, 0.603, 0.463, 0.389, 0.341, 0.308, 0.282, 0.262, 0.246, 0.232,
  61.                           0.22, 0.21, 0.202, 0.194, 0.187, 0.181, 0.175, 0.17, 0.166, 0.161,
  62.                           0.157, 0.153, 0.15, 0.147, 0.144, NA, NA, NA, NA, NA, NA, NA,
  63.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  64.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  65.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  66.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  67.                           NA, NA, NA, NA),
  68.                    d2 = c(1, 1.128, 1.693, 2.059, 2.326, 2.534,
  69.                           2.704, 2.847, 2.97, 3.078, 3.173, 3.258, 3.336, 3.407, 3.472,
  70.                           3.532, 3.588, 3.64, 3.689, 3.735, 3.778, 3.819, 3.858, 3.895,
  71.                           3.931, 3.965, 3.997, 4.028, 4.058, 4.086, 4.113, 4.139, 4.164,
  72.                           4.189, 4.213, 4.236, 4.258, 4.28, 4.301, 4.322, 4.342, 4.361,
  73.                           4.38, 4.398, 4.415, 4.432, 4.449, 4.466, 4.482, 4.498, NA, NA,
  74.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  75.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  76.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
  77.                    d3 = c(0.82, 0.8525, 0.8884, 0.8794, 0.8641, 0.848, 0.8332,
  78.                           0.8198, 0.8078, 0.7971, 0.7873, 0.7785, 0.7704, 0.763, 0.7562,
  79.                           0.7499, 0.7441, 0.7386, 0.7335, 0.7287, 0.7242, 0.7199, 0.7159,
  80.                           0.7121, 0.7084, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  81.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  82.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  83.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  84.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
  85.                    d4 = c(1, 0.954, 1.588, 1.978, 2.257, 2.472, 2.645, 2.791,
  86.                           2.915, 3.024, 3.121, 3.207, 3.285, 3.356, 3.422, 3.482, 3.538,
  87.                           3.591, 3.64, 3.686, 3.73, 3.771, 3.811, 3.847, 3.883, NA,
  88.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  89.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  90.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  91.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
  92.                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)),
  93.               .Names = c("N", "c4", "c5", "d2", "d3", "d4"), class = "data.frame",
  94.               row.names = c(NA, -100L))}
  95.    
  96.  
  97.   # Estimate the standard deviation within subgroups by the average of the moving range
  98.   # Add other methods here for subgroup size of 1
  99.  
  100.  
  101.   if (groupsize == 1){
  102.     R_i <- vector(mode = "numeric", length = (length(data[!is.na(data)])-(mrlength-1)))
  103.     range_temp <- vector(mode = "numeric", length = mrlength)
  104.     for(i in 1:(length(data[!is.na(data)])-(mrlength-1))){
  105.       for(j in i:(i+mrlength-1)){
  106.         range_temp[j+1-i]<-data[j]
  107.       }
  108.       R_i[i] <- max(range_temp) - min(range_temp)
  109.     }
  110.     Rbar <- sum(R_i)/(length(data[!is.na(data)])-(mrlength-1))
  111.    
  112.     if (unbias_sub) {
  113.       S_within <<- Rbar/(Lookup$d2[mrlength])
  114.       } else {
  115.       S_within <<- Rbar
  116.       }
  117.   }
  118.  
  119.   if (groupsize > 1){
  120.     #Add Here
  121.   }
  122.  
  123.   # Calculate overall standard deviation and apply the unbiasing constant if desired
  124.   if (unbias_overall) {
  125.     S_overall <- sd(data)/(Lookup$c4[length(data[!is.na(data)])])
  126.     } else {
  127.     S_overall <- sd(data)
  128.     }
  129.  
  130.   mu <- mean(data)
  131.  
  132.   # Process Data
  133.   {Proc_Data <- vector(mode = "numeric", length = 8)
  134.   names(Proc_Data) <- c("LSL","Target","USL","Sample Mean","Number of Obs.",
  135.                         "StDev(Within)","StDev(Overall)","Group Size")
  136.   Proc_Data["LSL"] <- LSL
  137.   Proc_Data["Target"] <- target
  138.   Proc_Data["USL"] <- USL
  139.   Proc_Data["Sample Mean"] <- mu
  140.   Proc_Data["Number of Obs."] <- length(data[!is.na(data)])
  141.   Proc_Data["StDev(Within)"] <- S_within
  142.   Proc_Data["StDev(Overall)"] <- S_overall
  143.   Proc_Data["Group Size"] <- groupsize}
  144.    
  145.   # Potential Capability Matrix
  146.   {CPS <- vector(mode = "numeric", length = 5)
  147.   names(CPS) <- c("Cp","CPL", "CPU", "Cpk", "CCpk")
  148.   CPS["Cp"] <- (USL - LSL)/(tol*S_within)
  149.   CPS["CPL"] <- (mu - LSL)/(.5*tol*S_within)
  150.   CPS["CPU"] <- (USL - mu)/(.5*tol*S_within)
  151.   CPS["Cpk"] <- min(CPS["CPU"],CPS["CPL"])
  152.   CPS["CCpk"] <- min(USL-target,target-LSL)/(.5*tol*S_within)}
  153.  
  154.   # Overall Capability Matrix
  155.   {PPS <- vector(mode = "numeric", length = 5)
  156.   names(PPS) <- c("Pp","PPL", "PPU", "Ppk", "Cpm")
  157.   PPS["Pp"] <- (USL - LSL)/(tol*S_overall)
  158.   PPS["PPL"] <- (mu - LSL)/(.5*tol*S_overall)
  159.   PPS["PPU"] <- (USL - mu)/(.5*tol*S_overall)
  160.   PPS["Ppk"] <- min(PPS["PPU"],PPS["PPL"])
  161.   PPS["Cpm"] <- CPS["Cp"]/sqrt(1+((mu-target)/S_within)^2)}
  162.  
  163.   #Expected Within/Overall/Observed Performance
  164.   {PERF <- vector(mode = "numeric", length = 9)
  165.   names(PERF) <- c("PWLL","PWGU","PWT","POLL","POGU","POT","OBLL","OBGU","OBT")
  166.   PERF["PWLL"] <- 1e6*(1-pnorm((mu-LSL)/S_within))
  167.   PERF["PWGU"] <- 1e6*(1-pnorm((USL-mu)/S_within))
  168.   PERF["PWT"] <- sum(PERF["PWLL"],PERF["PWGU"])
  169.   PERF["POLL"] <- 1e6*(1-pnorm((mu-LSL)/S_overall))
  170.   PERF["POGU"] <- 1e6*(1-pnorm((USL-mu)/S_overall))
  171.   PERF["POT"] <- sum(PERF["POLL"],PERF["POGU"])
  172.   PERF["OBLL"] <- 1e6*(length(data[data<LSL])/length(data[!is.na(data)]))
  173.   PERF["OBGU"] <- 1e6*(length(data[data>USL])/length(data[!is.na(data)]))
  174.   PERF["OBT"] <- sum(PERF["OBLL"],PERF["OBGU"])}
  175.  
  176.   if(plot){
  177.  
  178.   #Determine max densities for plot limits
  179.   if(density) dens_max <- max(density(data)[[2]]) else dens_max <- 0
  180.   freq_max <- max(hist(as.vector(data), plot = FALSE)$density)
  181.   with_max <- dnorm(mean(data), mean = mean(data),sd = S_within)
  182.   over_max <- dnorm(mean(data), mean = mean(data),sd = S_overall)
  183.    
  184.   #Calculate the binwidth if not specified
  185.   if (binwidth == -1) {
  186.     #Freedman-Diaconis
  187.     binwidth = 2 * IQR(data) / (length(data[!is.na(data)])^(1/3))
  188.     #Square-root choice
  189.     #binwidth = diff(range(data))/sqrt(length(data[!is.na(data)]))
  190.   }
  191.    
  192.   #Create Plots
  193.   data <- data.frame(data=data)
  194.  
  195.   #define function for aes that evaluates expressions
  196.   aes_now <- function(...) {structure(list(...),  class = "uneval")}
  197.  
  198.   #Initial plot definition
  199.   p <- ggplot(data, aes(x = data)) +
  200.               theme(plot.margin = unit(c(2,0,.5,0), "lines"),
  201.                     panel.grid.minor = element_blank(),
  202.                     panel.grid.major = element_blank(),
  203.                     panel.background = element_rect(fill = "white", color = "gray0"),
  204.                     plot.background = element_rect(fill = "cornsilk", color = NA),
  205.                     axis.title.y = element_blank(),
  206.                     axis.title.x = element_blank(),
  207.                     axis.ticks.y = element_blank(),
  208.                     axis.text.y = element_blank(),
  209.                     axis.text.x = element_text(size = 15),
  210.                     legend.background = element_rect(fill = "white", color = "gray0"),
  211.                     legend.key = element_rect(fill = NA, color = NA),
  212.                     legend.key.width = unit(3,"lines"),
  213.                     legend.key.height = unit(1,"lines")) +
  214.               coord_cartesian(ylim = c(0, max(1.05 * dens_max, 1.05 * freq_max,
  215.                                        1.05 * with_max, 1.05 * over_max)),
  216.                               xlim = c(min(min(data),
  217.                                            1.1 * LSL - 0.1 * USL, target - 3 * S_within,
  218.                                            target - 3 * S_overall),
  219.                                        max(max(data),
  220.                                            1.1 * USL - 0.1 * LSL, target + 3 * S_within,
  221.                                            target + 3 * S_overall))) +
  222.               xlim(min(min(data),
  223.                        1.1 * LSL - 0.1 * USL,
  224.                        target - 3 * S_within,
  225.                        target - 3 * S_overall),
  226.                    max(max(data),
  227.                        1.1 * USL - 0.1 * LSL,
  228.                        target + 3 * S_within,
  229.                        target + 3 * S_overall)) +
  230.               ylim(0, max(1.05 * dens_max, 1.05 * freq_max,
  231.                           1.05 * with_max, 1.05 * over_max))
  232.  
  233.   #Add histogram
  234.   p <- p + geom_histogram(aes(y=..density..),        
  235.                           binwidth = binwidth,
  236.                           color = "black", fill = "slategray1", position = "identity")
  237.  
  238.   #Add Density
  239.   if(density) {p <- p + geom_line(stat="density", size = 1.1,
  240.                                   aes(color = "density"), position="identity", linetype = 1)}
  241.   #Add Spec Limits and labels
  242.   p <- p + geom_vline(xintercept = LSL, linetype = 5, size = .65, color = "red3")
  243.   p <- p + geom_vline(xintercept = target, linetype = 5, size = .65, color = "green3")
  244.   p <- p + geom_vline(xintercept = USL, linetype = 5, size = .65, color = "red3")
  245.  
  246.   p <- p + geom_text(aes_now(label = c("USL"), x = c(USL), y = Inf, family = "sans"),
  247.                      hjust = .5, vjust = -1, color = "red3", size=4)
  248.   p <- p + geom_text(aes_now(label = c("LSL"), x = c(LSL), y = Inf, family = "sans"),
  249.                      hjust = .5, vjust = -1, color = "red3", size=4)
  250.   p <- p + geom_text(aes_now(label = c("Target"), x = c(target), y = Inf, family = "sans"),
  251.                      hjust = .5, vjust = -1, color = "green3", size=4)
  252.  
  253.   #Add within and overall distribution lines
  254.   p <- p + stat_function(fun = dnorm,args=list(mean = mu, sd = S_within),
  255.                          aes(color = "dwith", linetype = "dwith"), size = 1.1, linetype = 1)
  256.   p <- p + stat_function(fun = dnorm,args=list(mean = mu, sd = S_overall),
  257.                          aes(color = "dover", linetype = "dover"), size = 1.1, linetype = 2)
  258.  
  259.   #Add Legend (currently disabled by theme)
  260.   p <- p +    
  261.     scale_color_manual("Legend",
  262.                               labels = c("Within","Overall","Density"),
  263.                               breaks = c("dwith","dover","density"),
  264.                               values = c("dwith"="red3",
  265.                                          "dover"="gray0",
  266.                                          "density"="dodgerblue3"))
  267.  
  268.  
  269.   # Create Process Data Legend
  270.   Proc_leg <- {ggplot()+
  271.     xlim(c(0,1))+ylim(c(.2,1))+
  272.     theme(plot.margin = unit(c(2,0.1,2,0), "lines"),
  273.           panel.grid.minor = element_blank(),
  274.           panel.grid.major = element_blank(),
  275.           panel.background = element_rect(fill = "white", color = "gray0"),
  276.           plot.background = element_rect(fill = NA, color = NA),
  277.           axis.title.y = element_blank(),
  278.           axis.title.x = element_blank(),
  279.           axis.ticks.x = element_blank(),
  280.           axis.text.x = element_blank(),
  281.           axis.ticks.y = element_blank(),
  282.           axis.text.y = element_blank(),
  283.           legend.position = "none") +
  284.     geom_text(aes(label = c("Process Data"),
  285.                   x = .5, y = 1,
  286.                   family = "sans"),
  287.               hjust = .5, vjust = 1,
  288.               color = "gray0", size=4)+
  289.     geom_text(aes(label = c("LSL"),
  290.                   x = .05, y = .9,
  291.                   family = "sans"),
  292.               hjust = -.0, vjust = 1,
  293.               color = "gray0", size=4)+
  294.     geom_text(aes(label = c("Target"),
  295.                   x = .05, y = .8,
  296.                   family = "sans"),
  297.               hjust = -.0, vjust = 1,
  298.               color = "gray0", size=4)+
  299.     geom_text(aes(label = c("USL"),
  300.                   x = .05, y = .7,
  301.                   family = "sans"),
  302.               hjust = -.0, vjust = 1,
  303.               color = "gray0", size=4)+
  304.     geom_text(aes(label = c("Sample Mean"),
  305.                   x = .05, y = .6,
  306.                   family = "sans"),
  307.               hjust = -.0, vjust = 1,
  308.               color = "gray0", size=4)+
  309.     geom_text(aes(label = c("Sample N"),
  310.                   x = .05, y = .5,
  311.                   family = "sans"),
  312.               hjust = -.0, vjust = 1,
  313.               color = "gray0", size=4)+
  314.     geom_text(aes(label = c("StDev(Within)"),
  315.                   x = .05, y = .4,
  316.                   family = "sans"),
  317.               hjust = -.0, vjust = 1,
  318.               color = "gray0", size=4)+
  319.     geom_text(aes(label = c("StDev(Overall)"),
  320.                   x = .05, y = .3,
  321.                   family = "sans"),
  322.               hjust = -.0, vjust = 1,
  323.               color = "gray0", size=4)+
  324.    
  325.     geom_text(aes_now(label = sprintf("%.3f",LSL),
  326.                       x = .6, y = .9,
  327.                       family = "sans"),
  328.               hjust = -.0, vjust = 1,
  329.               color = "gray0", size=4)+
  330.     geom_text(aes_now(label = sprintf("%.3f",target),
  331.                       x = .6, y = .8,
  332.                       family = "sans"),
  333.               hjust = -.0, vjust = 1,
  334.               color = "gray0", size=4)+
  335.     geom_text(aes_now(label = sprintf("%.3f",USL),
  336.                       x = .6, y = .7,
  337.                       family = "sans"),
  338.               hjust = -.0, vjust = 1,
  339.               color = "gray0", size=4)+
  340.     geom_text(aes_now(label = sprintf("%.6f",mu),
  341.                       x = .6, y = .6,
  342.                       family = "sans"),
  343.               hjust = -.0, vjust = 1,
  344.               color = "gray0", size=4)+
  345.     geom_text(aes_now(label = length(data[!is.na(data)]),
  346.                       x = .6, y = .5,
  347.                       family = "sans"),
  348.               hjust = -.0, vjust = 1,
  349.               color = "gray0", size=4)+
  350.     geom_text(aes_now(label = sprintf("%.8f",S_within),
  351.                       x = .6, y = .4,
  352.                       family = "sans"),
  353.               hjust = -.0, vjust = 1,
  354.               color = "gray0", size=4)+
  355.     geom_text(aes_now(label = sprintf("%.8f",S_overall),
  356.                       x = .6, y = .3,
  357.                       family = "sans"),
  358.               hjust = -.0, vjust = 1,
  359.               color = "gray0", size=4)
  360.   }
  361.  
  362.   # Manually Create Chart Legend  
  363.   Leg_leg <- ggplot()+
  364.     xlim(c(0,1))+ylim(c(.2,1))+
  365.     theme(plot.margin = unit(c(2,1,6,0), "lines"),
  366.           panel.grid.minor = element_blank(),
  367.           panel.grid.major = element_blank(),
  368.           panel.background = element_rect(fill = "white", color = "gray0"),
  369.           plot.background = element_rect(fill = NA, color = NA),
  370.           axis.title.y = element_blank(),
  371.           axis.title.x = element_blank(),
  372.           axis.ticks.x = element_blank(),
  373.           axis.text.x = element_blank(),
  374.           axis.ticks.y = element_blank(),
  375.           axis.text.y = element_blank(),
  376.           legend.position = "none") +
  377.     geom_text(aes(label = c("Legend"),
  378.                   x = .5, y = .95,
  379.                   family = "sans"),
  380.               hjust = .5, vjust = 1,
  381.               color = "gray0", size=4) +
  382.     geom_segment(aes(x = .5, xend = .1, y = .65, yend = .65),
  383.                  size = 1, colour = "red3", linetype = 1,position = "identity")+
  384.     geom_segment(aes(x = .5, xend = .1, y = .475, yend = .475),
  385.                  size = 1, colour = "gray0", linetype = 2,position = "identity")+
  386.     geom_text(aes(label = c("Within"),
  387.                   x = .6, y =.65,
  388.                   family = "sans"),
  389.               hjust = 0, vjust = 0.2,
  390.               color = "gray0", size=4)+
  391.     geom_text(aes(label = c("Overall"),
  392.                   x = .6, y = .5,
  393.                   family = "sans"),
  394.               hjust = 0, vjust = 0.45,
  395.               color = "gray0", size=4)
  396.  
  397.     # check if density is plotted and add to legend
  398.     if(density){
  399.     Leg_leg <- Leg_leg +
  400.     geom_segment(aes(x = .5, xend = .1, y = .3, yend = .3),
  401.                      size = 1, colour = "dodgerblue3", linetype = 1,position = "identity") +
  402.     geom_text(aes(label = c("Density"),
  403.                   x = .6, y = .3,
  404.                   family = "sans"),
  405.               hjust = 0, vjust = 0.3,
  406.               color = "gray0", size=4)}
  407.  
  408.  
  409.   # Create Cp Legend
  410.   CPM_leg <- {ggplot()+
  411.     xlim(c(0,1))+ylim(c(0,1))+
  412.     theme(plot.margin = unit(c(6,1,7,0), "lines"),
  413.           panel.grid.minor = element_blank(),
  414.           panel.grid.major = element_blank(),
  415.           panel.background = element_rect(fill = "white", color = "gray0"),
  416.           plot.background = element_rect(fill = NA, color = NA),
  417.           axis.title.y = element_blank(),
  418.           axis.title.x = element_blank(),
  419.           axis.ticks.x = element_blank(),
  420.           axis.text.x = element_blank(),
  421.           axis.ticks.y = element_blank(),
  422.           axis.text.y = element_blank(),
  423.           legend.position = "none") +
  424.     geom_text(aes(label = c("Potential (Within) Capability"),
  425.                   x = .5, y = 1,
  426.                   family = "sans"),
  427.               hjust = .5, vjust = 1,
  428.               color = "gray0", size=4)+
  429.     geom_text(aes(label = c("Cp"),
  430.                   x = .2, y = .9,
  431.                   family = "sans"),
  432.               hjust = -.0, vjust = 1,
  433.               color = "gray0", size=4)+
  434.     geom_text(aes(label = c("Lower CL"),
  435.                   x = .2, y = .8,
  436.                   family = "sans"),
  437.               hjust = -.0, vjust = 1,
  438.               color = "gray0", size=4)+
  439.     geom_text(aes(label = c("Upper CL"),
  440.                   x = .2, y = .7,
  441.                   family = "sans"),
  442.               hjust = -.0, vjust = 1,
  443.               color = "gray0", size=4)+
  444.     geom_text(aes(label = c("CPL"),
  445.                   x = .2, y = .6,
  446.                   family = "sans"),
  447.               hjust = -.0, vjust = 1,
  448.               color = "gray0", size=4)+
  449.     geom_text(aes(label = c("CPU"),
  450.                   x = .2, y = .5,
  451.                   family = "sans"),
  452.               hjust = -.0, vjust = 1,
  453.               color = "gray0", size=4)+
  454.     geom_text(aes(label = c("Cpk"),
  455.                   x = .2, y = .4,
  456.                   family = "sans"),
  457.               hjust = -.0, vjust = 1,
  458.               color = "gray0", size=4)+
  459.     geom_text(aes(label = c("Lower CL"),
  460.                   x = .2, y = .3,
  461.                   family = "sans"),
  462.               hjust = -.0, vjust = 1,
  463.               color = "gray0", size=4)+
  464.     geom_text(aes(label = c("Upper CL"),
  465.                   x = .2, y = .2,
  466.                   family = "sans"),
  467.               hjust = -.0, vjust = 1,
  468.               color = "gray0", size=4)+
  469.     geom_text(aes(label = c("CCpk"),
  470.                   x = .2, y = .1,
  471.                   family = "sans"),
  472.               hjust = -.0, vjust = 1,
  473.               color = "gray0", size=4)+
  474.    
  475.     geom_text(aes_now(label = sprintf("%.3f",CPS["Cp"]),
  476.                       x = .6, y = .9,
  477.                       family = "sans"),
  478.               hjust = -.0, vjust = 1,
  479.               color = "gray0", size=4)+
  480.     geom_text(aes_now(label = sprintf("%.3s","-"),
  481.                       x = .6, y = .8,
  482.                       family = "sans"),
  483.               hjust = -.0, vjust = 1,
  484.               color = "gray0", size=4)+
  485.     geom_text(aes_now(label = sprintf("%.3s","-"),
  486.                       x = .6, y = .7,
  487.                       family = "sans"),
  488.               hjust = -.0, vjust = 1,
  489.               color = "gray0", size=4)+
  490.     geom_text(aes_now(label = sprintf("%.3f",CPS["CPL"]),
  491.                       x = .6, y = .6,
  492.                       family = "sans"),
  493.               hjust = -.0, vjust = 1,
  494.               color = "gray0", size=4)+
  495.     geom_text(aes_now(label = sprintf("%.3f",CPS["CPU"]),
  496.                       x = .6, y = .5,
  497.                       family = "sans"),
  498.               hjust = -.0, vjust = 1,
  499.               color = "gray0", size=4)+
  500.     geom_text(aes_now(label = sprintf("%.3f",CPS["Cpk"]),
  501.                       x = .6, y = .4,
  502.                       family = "sans"),
  503.               hjust = -.0, vjust = 1,
  504.               color = "gray0", size=4)+
  505.     geom_text(aes_now(label = sprintf("%.3s","-"),
  506.                       x = .6, y = .3,
  507.                       family = "sans"),
  508.               hjust = -.0, vjust = 1,
  509.               color = "gray0", size=4)+
  510.     geom_text(aes_now(label = sprintf("%.3s","-"),
  511.                       x = .6, y = .2,
  512.                       family = "sans"),
  513.               hjust = -.0, vjust = 1,
  514.               color = "gray0", size=4)+
  515.     geom_text(aes_now(label = sprintf("%.3f",CPS["CCpk"]),
  516.                       x = .6, y = .1,
  517.                       family = "sans"),
  518.               hjust = -.0, vjust = 1,
  519.               color = "gray0", size=4)
  520.   }
  521.  
  522.   #Create Pp Legend
  523.   PPM_leg <- {ggplot()+
  524.     xlim(c(0,1))+ylim(c(0,1))+
  525.     theme(plot.margin = unit(c(4,1,2,0), "lines"),
  526.           panel.grid.minor = element_blank(),
  527.           panel.grid.major = element_blank(),
  528.           panel.background = element_rect(fill = "white", color = "gray0"),
  529.           plot.background = element_rect(fill = NA, color = NA),
  530.           axis.title.y = element_blank(),
  531.           axis.title.x = element_blank(),
  532.           axis.ticks.x = element_blank(),
  533.           axis.text.x = element_blank(),
  534.           axis.ticks.y = element_blank(),
  535.           axis.text.y = element_blank(),
  536.           legend.position = "none") +
  537.     geom_text(aes(label = c("Overall Capability"),
  538.                   x = .5, y = 1,
  539.                   family = "sans"),
  540.               hjust = .5, vjust = 1,
  541.               color = "gray0", size=4)+
  542.     geom_text(aes(label = c("Pp"),
  543.                   x = .2, y = .9,
  544.                   family = "sans"),
  545.               hjust = -.0, vjust = 1,
  546.               color = "gray0", size=4)+
  547.     geom_text(aes(label = c("Lower CL"),
  548.                   x = .2, y = .8,
  549.                   family = "sans"),
  550.               hjust = -.0, vjust = 1,
  551.               color = "gray0", size=4)+
  552.     geom_text(aes(label = c("Upper CL"),
  553.                   x = .2, y = .7,
  554.                   family = "sans"),
  555.               hjust = -.0, vjust = 1,
  556.               color = "gray0", size=4)+
  557.     geom_text(aes(label = c("PPL"),
  558.                   x = .2, y = .6,
  559.                   family = "sans"),
  560.               hjust = -.0, vjust = 1,
  561.               color = "gray0", size=4)+
  562.     geom_text(aes(label = c("PPU"),
  563.                   x = .2, y = .5,
  564.                   family = "sans"),
  565.               hjust = -.0, vjust = 1,
  566.               color = "gray0", size=4)+
  567.     geom_text(aes(label = c("Ppk"),
  568.                   x = .2, y = .4,
  569.                   family = "sans"),
  570.               hjust = -.0, vjust = 1,
  571.               color = "gray0", size=4)+
  572.     geom_text(aes(label = c("Lower CL"),
  573.                   x = .2, y = .3,
  574.                   family = "sans"),
  575.               hjust = -.0, vjust = 1,
  576.               color = "gray0", size=4)+
  577.     geom_text(aes(label = c("Upper CL"),
  578.                   x = .2, y = .2,
  579.                   family = "sans"),
  580.               hjust = -.0, vjust = 1,
  581.               color = "gray0", size=4)+
  582.     geom_text(aes(label = c("Cpm"),
  583.                   x = .2, y = .1,
  584.                   family = "sans"),
  585.               hjust = -.0, vjust = 1,
  586.               color = "gray0", size=4)+
  587.    
  588.     geom_text(aes_now(label = sprintf("%.3f",PPS["Pp"]),
  589.                       x = .6, y = .9,
  590.                       family = "sans"),
  591.               hjust = -.0, vjust = 1,
  592.               color = "gray0", size=4)+
  593.     geom_text(aes_now(label = sprintf("%.3s","-"),
  594.                       x = .6, y = .8,
  595.                       family = "sans"),
  596.               hjust = -.0, vjust = 1,
  597.               color = "gray0", size=4)+
  598.     geom_text(aes_now(label = sprintf("%.3s","-"),
  599.                       x = .6, y = .7,
  600.                       family = "sans"),
  601.               hjust = -.0, vjust = 1,
  602.               color = "gray0", size=4)+
  603.     geom_text(aes_now(label = sprintf("%.3f",PPS["PPL"]),
  604.                       x = .6, y = .6,
  605.                       family = "sans"),
  606.               hjust = -.0, vjust = 1,
  607.               color = "gray0", size=4)+
  608.     geom_text(aes_now(label = sprintf("%.3f",PPS["PPU"]),
  609.                       x = .6, y = .5,
  610.                       family = "sans"),
  611.               hjust = -.0, vjust = 1,
  612.               color = "gray0", size=4)+
  613.     geom_text(aes_now(label = sprintf("%.3f",PPS["Ppk"]),
  614.                       x = .6, y = .4,
  615.                       family = "sans"),
  616.               hjust = -.0, vjust = 1,
  617.               color = "gray0", size=4)+
  618.     geom_text(aes_now(label = sprintf("%.3s","-"),
  619.                       x = .6, y = .3,
  620.                       family = "sans"),
  621.               hjust = -.0, vjust = 1,
  622.               color = "gray0", size=4)+
  623.     geom_text(aes_now(label = sprintf("%.3s","-"),
  624.                       x = .6, y = .2,
  625.                       family = "sans"),
  626.               hjust = -.0, vjust = 1,
  627.               color = "gray0", size=4)+
  628.     geom_text(aes_now(label = sprintf("%.3f",PPS["Cpm"]),
  629.                       x = .6, y = .1,
  630.                       family = "sans"),
  631.               hjust = -.0, vjust = 1,
  632.               color = "gray0", size=4)
  633.   }
  634.  
  635.   #Create Observed Performance Legend
  636.   OBS_leg <- {ggplot()+
  637.     xlim(c(0,1))+ylim(c(0.5,1))+
  638.     theme(plot.margin = unit(c(0,0.1,0,0), "lines"),
  639.           panel.grid.minor = element_blank(),
  640.           panel.grid.major = element_blank(),
  641.           panel.background = element_rect(fill = "white", color = "gray0"),
  642.           plot.background = element_rect(fill = NA, color = NA),
  643.           axis.title.y = element_blank(),
  644.           axis.title.x = element_blank(),
  645.           axis.ticks.x = element_blank(),
  646.           axis.text.x = element_blank(),
  647.           axis.ticks.y = element_blank(),
  648.           axis.text.y = element_blank(),
  649.           legend.position = "none") +
  650.     geom_text(aes(label = c("Observed Performance"),
  651.                   x = .5, y = .975,
  652.                   family = "sans"),
  653.               hjust = .5, vjust = 1,
  654.               color = "gray0", size=4)+
  655.     geom_text(aes(label = c("PPM < LSL"),
  656.                   x = .1, y = .85,
  657.                   family = "sans"),
  658.               hjust = -.0, vjust = 1,
  659.               color = "gray0", size=4)+
  660.     geom_text(aes(label = c("PPM > LSL"),
  661.                   x = .1, y = .75,
  662.                   family = "sans"),
  663.               hjust = -.0, vjust = 1,
  664.               color = "gray0", size=4)+
  665.     geom_text(aes(label = c("PPM Total"),
  666.                   x = .1, y = .65,
  667.                   family = "sans"),
  668.               hjust = -.0, vjust = 1,
  669.               color = "gray0", size=4)+
  670.    
  671.     geom_text(aes_now(label = sprintf("%.2f",PERF["OBLL"]),
  672.                       x = .6, y = .85,
  673.                       family = "sans"),
  674.               hjust = -.0, vjust = 1,
  675.               color = "gray0", size=4)+
  676.     geom_text(aes_now(label = sprintf("%.2f",PERF["OBGU"]),
  677.                       x = .6, y = .75,
  678.                       family = "sans"),
  679.               hjust = -.0, vjust = 1,
  680.               color = "gray0", size=4)+
  681.     geom_text(aes_now(label = sprintf("%.2f",PERF["OBT"]),
  682.                       x = .6, y = .65,
  683.                       family = "sans"),
  684.               hjust = -.0, vjust = 1,
  685.               color = "gray0", size=4)
  686.   }
  687.  
  688.   #Create Expected (Overall) Performance Legend
  689.   Eover_leg <- {ggplot()+
  690.     xlim(c(0,1))+ylim(c(0.5,1))+
  691.     theme(plot.margin = unit(c(0,.1,0,0), "lines"),
  692.           panel.grid.minor = element_blank(),
  693.           panel.grid.major = element_blank(),
  694.           panel.background = element_rect(fill = "white", color = "gray0"),
  695.           plot.background = element_rect(fill = NA, color = NA),
  696.           axis.title.y = element_blank(),
  697.           axis.title.x = element_blank(),
  698.           axis.ticks.x = element_blank(),
  699.           axis.text.x = element_blank(),
  700.           axis.ticks.y = element_blank(),
  701.           axis.text.y = element_blank(),
  702.           legend.position = "none") +
  703.     geom_text(aes(label = c("Exp. Overall Performance"),
  704.                   x = .5, y = .975,
  705.                   family = "sans"),
  706.               hjust = .5, vjust = 1,
  707.               color = "gray0", size=4)+
  708.     geom_text(aes(label = c("PPM < LSL"),
  709.                   x = .1, y = .85,
  710.                   family = "sans"),
  711.               hjust = -.0, vjust = 1,
  712.               color = "gray0", size=4)+
  713.     geom_text(aes(label = c("PPM > LSL"),
  714.                   x = .1, y = .75,
  715.                   family = "sans"),
  716.               hjust = -.0, vjust = 1,
  717.               color = "gray0", size=4)+
  718.     geom_text(aes(label = c("PPM Total"),
  719.                   x = .1, y = .65,
  720.                   family = "sans"),
  721.               hjust = -.0, vjust = 1,
  722.               color = "gray0", size=4)+
  723.    
  724.     geom_text(aes_now(label = sprintf("%.2f",PERF["POLL"]),
  725.                       x = .6, y = .85,
  726.                       family = "sans"),
  727.               hjust = -.0, vjust = 1,
  728.               color = "gray0", size=4)+
  729.     geom_text(aes_now(label = sprintf("%.2f",PERF["POGU"]),
  730.                       x = .6, y = .75,
  731.                       family = "sans"),
  732.               hjust = -.0, vjust = 1,
  733.               color = "gray0", size=4)+
  734.     geom_text(aes_now(label = sprintf("%.2f",PERF["POT"]),
  735.                       x = .6, y = .65,
  736.                       family = "sans"),
  737.               hjust = -.0, vjust = 1,
  738.               color = "gray0", size=4)
  739.   }
  740.  
  741.   #Create Expected (Within) Performance Legend
  742.   Ewith_leg <- {ggplot()+
  743.     xlim(c(0,1))+ylim(c(0.5,1))+
  744.     theme(plot.margin = unit(c(0,0.1,0,0), "lines"),
  745.           panel.grid.minor = element_blank(),
  746.           panel.grid.major = element_blank(),
  747.           panel.background = element_rect(fill = "white", color = "gray0"),
  748.           plot.background = element_rect(fill = NA, color = NA),
  749.           axis.title.y = element_blank(),
  750.           axis.title.x = element_blank(),
  751.           axis.ticks.x = element_blank(),
  752.           axis.text.x = element_blank(),
  753.           axis.ticks.y = element_blank(),
  754.           axis.text.y = element_blank(),
  755.           legend.position = "none") +
  756.     geom_text(aes(label = c("Exp. Within Performance"),
  757.                   x = .5, y = .975,
  758.                   family = "sans"),
  759.               hjust = .5, vjust = 1,
  760.               color = "gray0", size=4)+
  761.     geom_text(aes(label = c("PPM < LSL"),
  762.                   x = .1, y = .85,
  763.                   family = "sans"),
  764.               hjust = -.0, vjust = 1,
  765.               color = "gray0", size=4)+
  766.     geom_text(aes(label = c("PPM > LSL"),
  767.                   x = .1, y = .75,
  768.                   family = "sans"),
  769.               hjust = -.0, vjust = 1,
  770.               color = "gray0", size=4)+
  771.     geom_text(aes(label = c("PPM Total"),
  772.                   x = .1, y = .65,
  773.                   family = "sans"),
  774.               hjust = -.0, vjust = 1,
  775.               color = "gray0", size=4)+
  776.    
  777.     geom_text(aes_now(label = sprintf("%.2f",PERF["PWLL"]),
  778.                       x = .6, y = .85,
  779.                       family = "sans"),
  780.               hjust = -.0, vjust = 1,
  781.               color = "gray0", size=4)+
  782.     geom_text(aes_now(label = sprintf("%.2f",PERF["PWGU"]),
  783.                       x = .6, y = .75,
  784.                       family = "sans"),
  785.               hjust = -.0, vjust = 1,
  786.               color = "gray0", size=4)+
  787.     geom_text(aes_now(label = sprintf("%.2f",PERF["PWT"]),
  788.                       x = .6, y = .65,
  789.                       family = "sans"),
  790.               hjust = -.0, vjust = 1,
  791.               color = "gray0", size=4)
  792.   }
  793.  
  794.   #Create Q-Q Plot
  795.   y_qq <- quantile(as.numeric(data[,1]),c(.25,.75))
  796.   x_qq <- qnorm(c(.25,.75))
  797.   slope_qq <- diff(y_qq)/diff(x_qq)
  798.   int_qq <- y_qq[1L] - slope_qq * x_qq[1L]
  799.  
  800.   qq <- {ggplot(data, aes(sample=data, shape = 16, color = "red3")) +
  801.                stat_qq() + scale_shape_identity()+
  802.                geom_abline(slope = slope_qq, intercept = int_qq) +
  803.     theme(plot.margin = unit(c(11,0.1,4,0), "lines"),
  804.           panel.grid.minor = element_blank(),
  805.           panel.grid.major = element_blank(),
  806.           panel.background = element_rect(fill = "white", color = "gray0"),
  807.           plot.background = element_rect(fill = NA, color = NA),
  808.           axis.title.y = element_blank(),
  809.           axis.title.x = element_blank(),
  810.           axis.ticks.x = element_blank(),
  811.           axis.text.x = element_blank(),
  812.           axis.ticks.y = element_blank(),
  813.           axis.text.y = element_blank(),
  814.           legend.position = "none")
  815.   }
  816.  
  817.   #Create Q-Q Plot Legend
  818.   QQ_leg <- {ggplot()+ xlim(c(0,1))+ylim(c(0,1))+
  819.     theme(plot.margin = unit(c(-3,0.1,0,0), "lines"),
  820.           panel.grid.minor = element_blank(),
  821.           panel.grid.major = element_blank(),
  822.           panel.background = element_rect(fill = NA, color = NA),
  823.           plot.background = element_rect(fill = NA, color = NA),
  824.           axis.title.y = element_blank(),
  825.           axis.title.x = element_blank(),
  826.           axis.ticks.x = element_blank(),
  827.           axis.text.x = element_blank(),
  828.           axis.ticks.y = element_blank(),
  829.           axis.text.y = element_blank(),
  830.           legend.position = "none") +
  831.     geom_text(aes(label = c("Q-Q Plot"),
  832.                   x = .5, y = .95,
  833.                   family = "sans"),
  834.               hjust = .5, vjust = 1,
  835.               color = "gray0", size=4)+
  836.     geom_text(aes(label = c("Anderson-Darling Test"),
  837.                   x = .5, y = .25,
  838.                   family = "sans"),
  839.               hjust = .5, vjust = 1,
  840.               color = "gray0", size=4)+
  841.     geom_text(aes(label = c("Shapiro-Wilk Test"),
  842.                   x = .5, y = 0.1,
  843.                   family = "sans"),
  844.               hjust = .5, vjust = 1,
  845.               color = "gray0", size=4)+
  846.     geom_text(aes_now(label = paste("A = ", sprintf("%.5f",ad.test(as.matrix(data))[[1]]),
  847.                                     "       p = ", sprintf("%.5f",ad.test(as.matrix(data))[[2]]), sep=""),
  848.                     x = .5, y = .175,
  849.                     family = "sans"),
  850.               hjust = .5, vjust = 1,
  851.               color = "gray0", size=4)+
  852.     geom_text(aes_now(label = paste("W = ", sprintf("%.5f",shapiro.test(as.matrix(data))[[1]]),
  853.                                     "       p = ",sprintf("%.5f",shapiro.test(as.matrix(data))[[2]]), sep=""),
  854.                   x = .5, y = .025,
  855.                   family = "sans"),
  856.               hjust = .5, vjust = 1,
  857.               color = "gray0", size=4)
  858.   }
  859.  
  860.   #Initialize Plot Layout
  861.   #Builds 1x3 grid for title at top, footer at bottom and one large
  862.   #container in center to hold the ggplot object
  863.  
  864.     #Plot
  865.     grid.newpage()
  866.     vp.canvas<-viewport(name="canvas",
  867.                         width=unit(11,"inches"),
  868.                         height=unit(8.5,"inches"),
  869.                         layout=grid.layout(3,1,
  870.                         heights=unit(c(3,1,1), c("lines", "null", "lines"))))
  871.     pushViewport(vp.canvas)
  872.     grid.rect(gp=gpar(col="gray0",
  873.                       lwd=0,
  874.                       fill="cornsilk"))
  875.    
  876.     #Title
  877.     vp.title<-viewport(layout.pos.col=1,
  878.                        layout.pos.row=1,
  879.                        name="title")
  880.     pushViewport(vp.title)
  881.     grid.text(paste(main," of ", name, sep = ""),
  882.               gp=gpar(fontsize=18),
  883.               just = c("center","bottom"))
  884.     grid.text(paste("\n",sub),
  885.               gp=gpar(fontsize=15),
  886.               just = c("center","center"))
  887.     popViewport()
  888.    
  889.     #Footer
  890.     if(footer){
  891.     vp.subtitle<-viewport(layout.pos.col=1, layout.pos.row=3, name="footer")
  892.     pushViewport(vp.subtitle)
  893.     grid.text(R.Version()$version.string,
  894.               x = unit(1, "lines"),
  895.               gp=gpar(col="gray3",fontsize=10),
  896.               just = c("left","center"))
  897.     grid.text(format(Sys.time(), "%b %d, %Y"),
  898.               x = unit(1, "npc") - unit(1,"lines"),
  899.               gp=gpar(col="gray3",fontsize=10),
  900.               just = c("right","center"))
  901.     popViewport()}
  902.    
  903.     #Container
  904.     vp.container<-viewport(layout.pos.col=1, layout.pos.row=2, name="container")
  905.     pushViewport(vp.container)
  906.     grid.text ( "container")
  907.  
  908.     #Build the ggplot items
  909.     gt1 <- ggplot_gtable(ggplot_build(p))
  910.     gt2 <- ggplot_gtable(ggplot_build(Proc_leg))
  911.     gt3 <- ggplot_gtable(ggplot_build(Leg_leg))
  912.     gt4 <- ggplot_gtable(ggplot_build(CPM_leg))
  913.     gt5 <- ggplot_gtable(ggplot_build(PPM_leg))
  914.     gt6 <- ggplot_gtable(ggplot_build(OBS_leg))
  915.     gt7 <- ggplot_gtable(ggplot_build(Ewith_leg))
  916.     gt8 <- ggplot_gtable(ggplot_build(Eover_leg))
  917.     gt9 <- ggplot_gtable(ggplot_build(qq))
  918.     gt10 <- ggplot_gtable(ggplot_build(QQ_leg))
  919.  
  920.     #Disable clipping
  921.     #Required for hanging text above plot
  922.     gt1$layout$clip[gt1$layout$name == "panel"] <- "off"
  923.    
  924.     #Define a 4x4 gtable to hold the objects  
  925.     gt <- gtable(widths = unit(c(1, 1, 1, 1), "null"),
  926.                  height = unit(c(12, 1, 1, 5), c("lines", "null", "null", "lines")))
  927.    
  928.     #Add items to gtable locations  
  929.     gt <- gtable_add_grob(gt, gt1[,-5], 1, 2, b = 3, r = 3)
  930.     gt <- gtable_add_grob(gt, gt2[,], 1, 1)
  931.     gt <- gtable_add_grob(gt, gt3[,], 1, 4)
  932.     gt <- gtable_add_grob(gt, gt4[,], 1, 4, b = 3)
  933.     gt <- gtable_add_grob(gt, gt5[,], 2, 4, b = 4)
  934.     gt <- gtable_add_grob(gt, gt6[,], 4, 1)
  935.     gt <- gtable_add_grob(gt, gt7[,], 4, 2)
  936.     gt <- gtable_add_grob(gt, gt8[,], 4, 3)
  937.     gt <- gtable_add_grob(gt, gt9[,], 1, 1, b = 3)
  938.     gt <- gtable_add_grob(gt, gt10[,], 2, 1, b= 3)
  939.  
  940.   #Render the plot  
  941.   grid.draw(gt)
  942.  
  943. }
  944.  
  945.   #Define output
  946.   output <- list(Proc_Data,CPS,PPS,PERF)
  947.   class(output) <- 'myclass'
  948.   return(output)
  949. }
  950.  
  951. #Format Text Output
  952. print.myclass <- function(x) {
  953.   cat("Capabiliy Analysis","\n")
  954.   print(noquote(cbind(`Process Data` = unlist(x[[1]]))), digits = 4)
  955.   cat("\n")
  956.   print(noquote(cbind(`Potential Capability` = unlist(x[[2]]))), digits = 4)
  957.   cat("\n")
  958.   print(noquote(cbind(`Overall Capability` = unlist(x[[3]]))), digits = 4)
  959.   cat("\n")
  960.   print(noquote(cbind(`Performance` = unlist(x[[4]]))), digits = 4)
  961.   return(invisible(x))
  962. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement