#' Tally Shifts
#'
#' Takes a tidy schedule generated by `load_tidy_schedule()` and generates a
#' table of shift tallies per doctor.
#'
#' @param tidy_schedule A tibble generated by `load_tidy_schedule()`.
#'
#' @return A tibble with tallies of shift types per doctor.
#' @export
#' @seealso [medinetparser::load_tidy_schedule()]
#' @md
#'
#' @examples
#' tally_table <- tally_shifts(example_schedule)
tally_shifts <- function(tidy_schedule) {
NULL ->
doctor_name ->
shift_type ->
n
tidy_schedule |>
dplyr::group_by(doctor_name, shift_type) |>
dplyr::tally() |>
tidyr::pivot_wider(names_from = shift_type, values_from = n) |>
dplyr::mutate(dplyr::across(dplyr::everything(), ~ tidyr::replace_na(.x, 0))) |>
(\(x) return(x))()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.