HorridTom / hospitalflow

0 stars 0 forks source link

autospc warnings and errors #133

Open Wartynas opened 2 years ago

Wartynas commented 2 years ago

There is one hospitalflow function - plot_ed_4hourperf_timeseries - that is integrated with autospc package on enhance-integrate_autospc-130 branch.

hospitalflow::plot_ed_4hourperf_timeseries(ed_data, startDate = "2019-01-01", endDate = "2019-06-01", returnPlot = TRUE) function call inside the branch mentioned above produces the desired autospc-like plot:

image

But it also throws some warnings:

Warning messages:
1: In if (xType != "Date" & all(xType != c("POSIXct", "POSIXt")) &  :
  the condition has length > 1 and only the first element will be used
2: In if (xType == "Date" | xType == "POSIXct" | xType == "POSIXt") { :
  the condition has length > 1 and only the first element will be used
3: In if (xType == "Date" | xType == "POSIXct" | xType == "POSIXt") { :
  the condition has length > 1 and only the first element will be used

These 3 warnings are printed every time when the time period limited by endDate and startDate is equal to or more than 21 day. In addition, when the 2 parameters indicate a time period shorter than 21 day, an error is thrown (regardless of minPeriod specified in autospc::plot_auto_spc, where the default value is 21). For example, hospitalflow::plot_ed_4hourperf_timeseries(ed_data, startDate = "2019-01-01", endDate = "2019-01-20", returnPlot = TRUE) returns:

Error in UseMethod("mutate") : 
  no applicable method for 'mutate' applied to an object of class "character"
In addition: Warning message:
In if (xType != "Date" & all(xType != c("POSIXct", "POSIXt")) & 

Traceback:

4. dplyr::mutate(., limitChange = ifelse(periodType == dplyr::lag(periodType), FALSE, TRUE))
3. df %>% dplyr::mutate(limitChange = ifelse(periodType == dplyr::lag(periodType),  FALSE, TRUE))
2. autospc::plot_auto_SPC(df = sum_4hrs_perf, chartType = "P'",  x = "Time", b = "under_4hrs", n = "N", plotChart = TRUE) at plot_ed_4hourperf_timeseries.R#92
1. hospitalflow::plot_ed_4hourperf_timeseries(ed_data, startDate = "2019-01-01",  endDate = "2019-01-20", returnPlot = TRUE)

I get the same error when running devtools::test(), presumably due to the insufficient number of datapoints testing data.

For anyone (@HorridTom ?) who looks into this issue - please let me know if you were able to reproduce the error.

Wartynas commented 2 years ago

I just noticed that Imogen created a very similar issue 16 days ago in autospc repo: https://github.com/HorridTom/autospc/issues/79