"Error in plot.window(...) : need finite 'ylim' values" - SPC charts in R

14.1k Views Asked by At

I'm using the qcc package in R to try and generate an SPC 'R chart':

library(qcc)
my.data <- read.csv("/Users/Me/Desktop/data.csv",header=FALSE)

The data are read OK, and I get no error messages if I try:

summary(my.data)

However, if I then try to create the actual chart:

q1 <- qcc(my.data, type="R", nsigmas=3)

then I get an error message:

Error in plot.window(...) : need finite 'ylim' values

I've done a bit of reading online and the most common cause of this seems to be missing or 'NA' values in the data, but there are numeric values for every data point in my dataset. I've also tried declaring ylim explicitly:

q1 <- qcc(my.data, type="R", nsigmas=3, ylim=300)

but that gives me the error message:

Error in plot.window(...) : invalid 'ylim' value

I'd be grateful for any suggestions as to what to try next. Full dataset is included below via dput (shown in RStudio as "16 observations of 34 variables", which is correct). Thanks!

structure(list(V1 = c(109L, 99L, 93L, 79L, 90L, 59L, 102L, 104L, 98L, 98L, 104L, 85L, 107L, 98L, 76L, 54L), V2 = c(153L, 115L, 120L, 136L, 104L, 114L, 106L, 139L, 124L, 144L, 114L, 129L, 130L, 144L, 137L, 147L), V3 = c(167L, 162L, 156L, 173L, 151L, 169L, 160L, 151L, 132L, 140L, 137L, 192L, 164L, 155L, 182L, 112L), V4 = c(99L, 99L, 92L, 93L, 98L, 118L, 134L, 137L, 130L, 136L, 133L, 126L, 113L, 111L, 94L, 85L), V5 = c(140L, 87L, 123L, 111L, 80L, 98L, 59L, 81L, 64L, 83L, 105L, 86L, 103L, 117L, 109L, 51L), V6 = c(177L, 124L, 160L, 138L, 145L, 119L, 132L, 103L, 116L, 103L, 136L, 172L, 165L, 165L, 160L, 151L), V7 = c(219L, 156L, 149L, 136L, 165L, 163L, 144L, 175L, 155L, 196L, 165L, 161L, 168L, 170L, 196L, 123L), V8 = c(104L, 95L, 90L, 87L, 122L, 94L, 87L, 108L, 108L, 105L, 123L, 124L, 157L, 122L, 132L, 123L), V9 = c(80L, 67L, 85L, 79L, 65L, 69L, 81L, 62L, 68L, 68L, 81L, 76L, 100L, 89L, 96L, 64L), V10 = c(90L, 66L, 82L, 89L, 100L, 62L, 61L, 58L, 44L, 79L, 54L, 62L, 53L, 62L, 78L, 48L), V11 = c(65L, 62L, 55L, 58L, 64L, 69L, 74L, 53L, 62L, 53L, 76L, 67L, 109L, 83L, 95L, 62L), V12 = c(66L, 58L, 80L, 62L, 70L, 61L, 80L, 81L, 67L, 94L, 61L, 63L, 80L, 77L, 80L, 69L), V13 = c(70L, 88L, 61L, 81L, 59L, 61L, 69L, 85L, 68L, 72L, 50L, 81L, 70L, 82L, 81L, 56L), V14 = c(155L, 142L, 156L, 117L, 125L, 119L, 115L, 110L, 109L, 124L, 109L, 137L, 117L, 115L, 119L, 76L), V15 = c(167L, 124L, 139L, 162L, 137L, 138L, 128L, 131L, 132L, 147L, 150L, 156L, 151L, 131L, 117L, 112L), V16 = c(139L, 113L, 121L, 99L, 95L, 83L, 78L, 89L, 98L, 79L, 110L, 93L, 87L, 68L, 97L, 80L), V17 = c(79L, 49L, 70L, 79L, 64L, 63L, 81L, 89L, 82L, 80L, 62L, 93L, 71L, 62L, 63L, 46L), V18 = c(99L, 83L, 126L, 110L, 116L, 104L, 110L, 105L, 122L, 117L, 129L, 113L, 155L, 128L, 130L, 116L), V19 = c(69L, 73L, 72L, 88L, 96L, 99L, 96L, 89L, 96L, 102L, 78L, 76L, 105L, 107L, 79L, 54L), V20 = c(114L, 97L, 100L, 95L, 106L, 115L, 121L, 119L, 124L, 113L, 91L, 93L, 80L, 82L, 83L, 67L), V21 = c(122L, 110L, 121L, 105L, 116L, 98L, 136L, 130L, 96L, 110L, 113L, 123L, 134L, 104L, 120L, 128L), V22 = c(61L, 77L, 88L, 101L, 89L, 70L, 64L, 63L, 81L, 69L, 79L, 79L, 78L, 83L, 81L, 69L), V23 = c(114L, 86L, 103L, 93L, 102L, 95L, 83L, 102L, 87L, 81L, 67L, 84L, 82L, 63L, 87L, 65L), V24 = c(80L, 81L, 96L, 69L, 70L, 77L, 84L, 71L, 82L, 80L, 59L, 59L, 56L, 45L, 74L, 54L), V25 = c(69L, 41L, 65L, 62L, 62L, 68L, 37L, 44L, 54L, 46L, 48L, 50L, 46L, 40L, 44L, 31L), V26 = c(155L, 129L, 117L, 164L, 129L, 128L, 125L, 118L, 92L, 103L, 94L, 120L, 129L, 107L, 130L, 111L), V27 = c(87L, 79L, 92L, 78L, 73L, 57L, 85L, 79L, 87L, 99L, 78L, 88L, 88L, 94L, 69L, 54L), V28 = c(142L, 165L, 205L, 220L, 162L, 188L, 176L, 150L, 194L, 202L, 169L, 168L, 239L, 181L, 187L, 134L), V29 = c(123L, 103L, 93L, 102L, 106L, 108L, 114L, 85L, 91L, 95L, 112L, 138L, 92L, 94L, 117L, 101L), V30 = c(109L, 96L, 113L, 99L, 105L, 83L, 118L, 119L, 97L, 93L, 105L, 106L, 122L, 101L, 86L, 59L), V31 = c(99L, 105L, 108L, 105L, 137L, 92L, 81L, 107L, 92L, 83L, 86L, 92L, 74L, 68L, 97L, 51L), V32 = c(126L, 95L, 105L, 96L, 87L, 70L, 78L, 74L, 97L, 101L, 95L, 97L, 106L, 71L, 89L, 67L), V33 = c(115L, 94L, 109L, 126L, 122L, 111L, 99L, 101L, 109L, 94L, 102L, 84L, 74L, 87L, 79L, 62L), V34 = c(87L, 112L, 94L, 97L, 123L, 105L, 102L, 97L, 101L, 107L, 106L, 120L, 125L, 120L, 110L, 75L)), .Names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19", "V20", "V21", "V22", "V23", "V24", "V25", "V26", "V27", "V28", "V29", "V30", "V31", "V32", "V33", "V34"), class = "data.frame", row.names = c(NA, -16L))
1

There are 1 best solutions below

0
On BEST ANSWER

Add the ylim as vector:

qcc::qcc(my.data, type="R", nsigmas=3, ylim=c(0,300))

produces:

enter image description here