0

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.

I want to hide the "+" points in the following chart: enter image description here

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")
CanofDrink
  • 89
  • 9

1 Answers1

1

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). Then source the modified function into your workspace. Finally, tell R to use the version you just created with:

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).

How to get a copy of the code: Go to a CRAN mirror like this one. 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. Click the link for "package source", currently "qcc_2.6.tar.gz" and download to your computer. Unpack it, it should give you a folder. Look for the R folder within that folder, then look for 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. 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

Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
  • I understand the idea, but I don't know where to find the code so instructions would be great. This doesn't seem like something I could've figured out myself so I'm glad I've not asked a stupid question haha. Thanks. – CanofDrink Jan 24 '16 at 12:27
  • 1
    I don't know what those + signs are, but the author of `qcc` didn't allow for them to be optional, so this is the kind of thing you have to do. I added instructions for finding the code to my answer. – Bryan Hanson Jan 24 '16 at 13:03
  • Perfect. Thanks for the tutorial, will definitely try to use it again next time I have trouble! Might even try to modify one of the existing functions to create a median control chart since there isn't a function for one in qcc. – CanofDrink Jan 24 '16 at 13:32
  • Super, now you are a Hacker! Have fun. If you've got the answer you need, you can hover below the voting area on the left and mark your question as answered with the green check. – Bryan Hanson Jan 24 '16 at 13:36