简体   繁体   English

在R的qcc软件包中使用ewma时隐藏点(控制图)

[英]Hide Points When Using ewma in the qcc Package in R (Control Charts)

Tried q5[4]<-NULL twice since they hold the values for the points I want to get rid of but then I get an error saying that the 'x' and 'y' lengths differ. 尝试过q5[4]<-NULL两次,因为它们保存了我想要摆脱的点的值,但是随后出现一个错误,指出“ x”和“ y”的长度不同。

I want to hide the "+" points in the following chart: 我想在下表中隐藏“ +”点: 在此处输入图片说明

Here's the code: 这是代码:

q5data<-structure(list(x = c(1045L, 1055L, 1037L, 1064L, 1095L, 1008L, 
1050L, 1087L, 1125L, 1146L, 1139L, 1169L, 1151L, 1128L, 1238L, 
1125L, 1163L, 1188L, 1146L, 1167L)), .Names = "x", class = "data.frame",row.names = c(NA, 
-20L))

library(qcc)
qcc.options(bg.margin = "transparent")
q5<-ewma(q5data, center=1050,nsigmas=2.7,lambda=0.1,ylab="Molecular Weight",xlab="Observation",title="EWMA Chart for Molecular Weight")

Looking at the code for plot.ewma.qcc , to remove those points you would have to hack the function by commenting out the line points(indices, statistics, pch = 3, cex = 0.8) . 查看plot.ewma.qcc的代码,要删除这些点,您必须通过注释掉行points(indices, statistics, pch = 3, cex = 0.8)来破解函数。 Then source the modified function into your workspace. 然后将修改后的函数来源到您的工作区中。 Finally, tell R to use the version you just created with: 最后,告诉R使用您刚刚创建的版本:

assignInNamespace("plot.ewma.qcc", plot.ewma.qcc, pos = "package:qcc")

and then run your plot command, q5 <- ewma(...) You will need to pass an explicit ylim as well as plot.ewma.qcc computes one if you don't, and they include the value of those points in their range computation (which leaves a lot of whitespace in your plot). 然后运行您的plot命令, q5 <- ewma(...)您将需要传递一个明确的ylim以及plot.ewma.qcc如果不这样做,将计算一个值,并且将这些点的值包括在范围计算(在绘图中留出很多空白)。

How to get a copy of the code: Go to a CRAN mirror like this one . 如何获得代码的副本:去一个CRAN镜像这样的一个 On the left side, choose "packages", then choose the 2nd link "table of available packages, sorted by name". 在左侧,选择“软件包”,然后选择第二个链接“可用软件包表,按名称排序”。 Scroll down to "qcc" and click on that link. 向下滚动到“ qcc”,然后单击该链接。 Click the link for "package source", currently "qcc_2.6.tar.gz" and download to your computer. 单击“包源”(当前为“ qcc_2.6.tar.gz”)的链接,然后下载到您的计算机。 Unpack it, it should give you a folder. 打开包装,它会给您一个文件夹。 Look for the R folder within that folder, then look for ewma.R. 在该文件夹中寻找R文件夹,然后寻找ewma.R。 Open this in a text editor, search for plot.ewma.qcc You might want to copy this entire function out to a new folder if you will use this regularly. 在文本编辑器中打开它,搜索plot.ewma.qcc。如果您要定期使用此功能,则可能要将整个功能复制到新文件夹中。 Then edit it as described above. 然后如上所述进行编辑。 Be sure you get the whole function, all the way to the closing brace. 确保获得整个功能,一直到右括号。 Looks like lines 221 - 353. While that's the process to access code for any package, you can also go directly to the package page like this: http://cloud.r-project.org/package=qcc 看起来像221-353行。虽然这是访问任何软件包代码的过程,但是您也可以像这样直接进入软件包页面: http : //cloud.r-project.org/package=qcc

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

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