Closed S-KD closed 4 years ago
Can you provide a minimal reproducible example?
library(qcc)
set.seed(0) data = matrix(rnorm(100),nrow=20,ncol=5) newdata1 = matrix(rnorm(5),nrow=1,ncol=5) newdata2 = matrix(rnorm(20),nrow=4,ncol=5)
q <- mqcc(data, type="T2.single",confidence.level=0.975, pred.limits=T,newdata=newdata1)
q <- mqcc(data, type="T2.single",confidence.level=0.975, pred.limits=T,newdata=newdata1,newlabels="newdata1")
q <- mqcc(data, type="T2.single",confidence.level=0.975, pred.limits=T,newdata=newdata2)
The bug has been fixed in the current version of the package available in GitHub.
In function mqcc with type "T2.single", if newdata has less than 4 observations and newlabels are not set then functions give an error due to lines 79 and 80. according to my tests, the problem is "length(newstats)" as this will evaluate to be 4. So, I propose following to resolve this error:
Following two lines instead of line 79: new_m <- unique(sapply(newdata, nrow)) newlabels <- seq(start + 1, start + new_m)
and then following line instead of line 80: if (length(newlabels) != new_m)