1

I am trying to create a control chart using the code below but I am getting the error below. The data has the first Column as date then 12 other columns with different variables of data.

library("qcc")

attach(data)

Data_Frame_Data <- as.data.frame.matrix(data)


q <- qcc(Cancer_Activity
         , type="xbar"
         , nsigmas=3)

Error in sd.xbar(c(1396310400, 1398902400, 1401580800, 1404172800, 1406851200, : group sizes must be larger than one

This is the output when I run str(data)

Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   48 obs. of  13 variables:
 $ Date         : POSIXct, format: "2014-04-01" "2014-05-01" "2014-06-01" "2014-07-01" ...
 $ CW_Activity  : num  37 29.5 34 46 39.5 41.5 42 40 46 39.5 ...
 $ CW_Breach    : num  3.5 6 8.5 10 5.5 8 4.5 3 3.5 4 ...
 $ ICHT_Activity: num  73.5 89 60 83.5 85 88.5 65.5 80 75.5 74 ...
 $ ICHT_Breach  : num  8 11.5 11.5 12 11 15 9.5 14 8.5 16.5 ...
 $ LNWH_Activity: num  67 76.5 56 79.5 67 83 77.5 67 66 60.5 ...
 $ LNWH_Breach  : num  10 12.5 13 14 10.5 16 16.5 12 5 13.5 ...
 $ THH_Activity : num  30 26 24.5 36 31 25 33 21.5 42 25.5 ...
 $ THH_Breach   : num  2 3 2 1 5 1.5 3.5 0.5 3.5 3 ...
 $ RBH_Activity : num  2.5 5 6.5 7 6.5 7.5 3.5 9 8 6.5 ...
 $ RBH_Breach   : num  0.5 1 2 2 4 4 1 2 2.5 2 ...
 $ NWL_Activity : num  210 226 181 252 229 ...
 $ NWL_Breach   : num  24 34 37 39 36 44.5 35 31.5 23 39 ...
James Anon
  • 31
  • 1
  • 6
  • Thanks, I have just added it in. – James Anon Nov 01 '17 at 12:14
  • Yes, I get the same error message. – James Anon Nov 01 '17 at 13:53
  • When I change the data for the data for the data frame that I have created I get this error message : Error in data.matrix(data) : (list) object cannot be coerced to type 'double' – James Anon Nov 01 '17 at 14:00
  • Please, start a new R session and run this code: https://pastebin.com/myB64q89 Let me know what you get. – Marco Sandri Nov 01 '17 at 14:28
  • This has worked! Is there any way of having the dates on the x axis? And how do you specify which column you want to use? – James Anon Nov 01 '17 at 14:34
  • I have just tried that and it comes up with this error, Error: Column `Cancer_Activity` must be a 1d atomic vector or a list – James Anon Nov 01 '17 at 14:52
  • It is the name of my data table. Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 48 obs. of 13 variables: $ Date : POSIXct, format: "2014-04-01" "2014-05-01" "2014-06-01" "2014-07-01" ... $ CW_Activity : num 37 29.5 34 46 39.5 41.5 42 40 46 39.5 ... $ CW_Breach : num 3.5 6 8.5 10 5.5 8 4.5 3 3.5 4 ... $ ICHT_Activity: num 73.5 89 60 83.5 85 88.5 65.5 80 75.5 74 ... $ ICHT_Breach : num 8 11.5 11.5 12 11 15 9.5 14 8.5 16.5 ... $ LNWH_Activity: num 67 76.5 56 79.5 67 83 77.5 67 66 60.5 ... The rest does not fit on here – James Anon Nov 01 '17 at 15:13
  • The data frame is a subset of all the data in `Cancer_Activity`. If i understand correctly, `data` is a subset of `Cancer_Activity` – James Anon Nov 01 '17 at 15:22
  • Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 48 obs. of 13 variables: $ Date : POSIXct, format: "2014-04-01" "2014-05-01" "2014-06-01" "2014-07-01" ... $ CW_Activity : num 37 29.5 34 46 39.5 41.5 42 40 46 39.5 ... $ CW_Breach : num 3.5 6 8.5 10 5.5 8 4.5 3 3.5 4 ... $ ICHT_Activity: num 73.5 89 60 83.5 85 88.5 65.5 80 75.5 74 ... $ ICHT_Breach : num 8 11.5 11.5 12 11 15 9.5 14 8.5 16.5 ... $ LNWH_Activity: num 67 76.5 56 79.5 67 83 77.5 67 66 60.5 ... $ LNWH_Breach : num 10 12.5 13 14 10.5 16 16.5 12 5 13.5 ... – James Anon Nov 01 '17 at 16:13
  • Yes they are the same object. – James Anon Nov 02 '17 at 09:01

0 Answers0