简体   繁体   English

访问控制图结果为R?

[英]Accessing control chart results in R?

I have a short R script that loads a bunch of data and plots it in an XBar chart. 我有一个简短的R脚本,可以加载大量数据并将其绘制在XBar图表中。 Using the following code, I can plot the data and view the various statistical information. 使用以下代码,我可以绘制数据并查看各种统计信息。

library(qcc)
tir<-read.table("data.dat", header=T,,sep="\t")
names(tir)
attach(tir)
rand <- sample(tir)
xbarchart <- qcc(rand[1:100,],type="R")
summary(xbarchart)

I want to be able to do some process capability analysis (described here (PDF) on page 5) immediately after the XBar chart is created. 创建XBar图表后,我希望能够立即进行一些过程能力分析( 在此处第5页(PDF)进行介绍)。 In order to create the analysis chart, I need to store the LCL and UCL results from the XBar chart results created before as variables. 为了创建分析图,我需要将之前创建的XBar图表结果的LCL和UCL结果存储为变量。 Is there any way I can do this? 有什么办法可以做到吗?

I shall answer your question using the example in the ?qcc help file. 我将使用?qcc帮助文件中的示例回答您的问题。

x <- c(33.75, 33.05, 34, 33.81, 33.46, 34.02, 33.68, 33.27, 33.49, 33.20,
    33.62, 33.00, 33.54, 33.12, 33.84)

xbarchart <- qcc(x, type="xbar.one", std.dev = "SD")

A useful function to inspect the structure of variables and function results is str() , short for structure. 检查变量结构和函数结果的有用函数是str() ,它是结构的缩写。

str(xbarchart)

List of 11
 $ call      : language qcc(data = x, type = "xbar.one", std.dev = "SD")
 $ type      : chr "xbar.one"
 $ data.name : chr "x"
 $ data      : num [1:15, 1] 33.8 33 34 33.8 33.5 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ Group  : chr [1:15] "1" "2" "3" "4" ...
  .. ..$ Samples: NULL
 $ statistics: Named num [1:15] 33.8 33 34 33.8 33.5 ...
  ..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
 $ sizes     : int [1:15] 1 1 1 1 1 1 1 1 1 1 ...
 $ center    : num 33.5
 $ std.dev   : num 0.342
 $ nsigmas   : num 3
 $ limits    : num [1, 1:2] 32.5 34.5
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr ""
  .. ..$ : chr [1:2] "LCL" "UCL"
 $ violations:List of 2
  ..$ beyond.limits : int(0) 
  ..$ violating.runs: num(0) 
 - attr(*, "class")= chr "qcc"

You will notice the second to last element in this list is called $limits and contains the two values for LCL and UCL. 您会注意到此列表中倒数第二个元素称为$ limits,其中包含LCL和UCL的两个值。

It is simple to extract this element: 提取此元素很简单:

limits <- xbarchart$limits
limits

      LCL      UCL
 32.49855 34.54811

Thus LCL <- limits[1] and UCL <- limits[2] 因此, LCL <- limits[1]UCL <- limits[2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM