get_wait_times_all: Get wait times for emergencies, consultations, and surgeries...

Description Usage Arguments Value Examples

Description

This function loops across all hospital IDs and runs get_wait_times in order to extract all wait times

Usage

1
2
3
get_wait_times_all(output_format = c("json", "data_frame"),
  request_headers = "", data_type = c("emergency", "consultation",
  "surgery"), sleep_time = 1)

Arguments

output_format

defines the format of the final output resulting form the API call. Two options: (1) output_format = "data_frame" returns a tibble object; (2) output_format = "json" returns the data as a json file

request_headers

named character vector with the HTTP headers to be added to GET via add_headers. Defaults to NULL

data_type

Character string determining the type of data to request. Can be either (1) "emergency", (2) "consultation", or "surgery"

sleep_time

Integer defining the number of seconds to wait between API calls. Strongly recomend setting a sleeper time so as to not overloading the server. Defaults to 3 seconds.

Value

list with json strings or tibble. The relevant wait times for "emergency" are in both seconds as integer or ymd_hms. For "consultation" or "surgery" they unit of analysis is day as integer. All datasets also contain a variable measuring wait times by the number of people waiting.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(esperaR)

## Not run: 
library(ggplot2)
## extract emergency data as a data frame
wait_dta <- get_wait_times_all(output_format = "data_frame", data_type = "consultation")

wait_dta %>%
 group_by(priority) %>%
 summarise(mean_wait_time = mean(as.integer(days), na.rm = TRUE)) %>%
 ungroup() %>%
 top_n(mean_wait_time, 10) %>%
 ggplot(aes(priority, mean_wait_time)) +
 geom_boxplot() +
 coord_flip()

## End(Not run)

josemreis/esperaR documentation built on March 31, 2020, 1:50 a.m.