nhs-r-community / NHSRplotthedots

An SPC package to support NHSE/I 'Making Data Count' programme
https://nhs-r-community.github.io/NHSRplotthedots/
Other
48 stars 23 forks source link

Functionality for hourly SPC #201

Closed plotstudata closed 11 months ago

plotstudata commented 11 months ago

It was great to be able to quickly add SPC to reporting last week. Is there a capability to provide SPC reporting by the hour or is date_field constrained to be full days only? I am thinking of processes where hourly output can be measured e.g. clinical coding outputs or ED discharges. I was planning on restricting it to only certain times of the day (for the clinical coders) and would envisage today to have x-axis of 2/1/2024_9 (for 9 am to 10 am) and 2/1/2024_10 (for 10 am to 11 am) etc?

tomjemmett commented 11 months ago

It accepts date times, but you may want to customise the date labels:

library(tidyverse)
library(NHSRplotthedots)

set.seed(123)
tibble(
  # simulate hourly data for 1 day, but if you pass in any datetime field it should work
  time = as.POSIXct("2024-01-01") +  0:23 * 60 * 60,
  v = rpois(24, 100)
) |>
  ptd_spc(v, time) |>
  plot(x_axis_date_format = "%d/%m/%y %H:%M:%S")