Generate counts of beddays per month for an episode with an admission and discharge date Optionally these months can be between two supplied dates

monthly_beddays_and_admissions(
  data,
  admission_var,
  discharge_var,
  earliest_date = NA,
  latest_date = NA,
  pivot_longer = TRUE
)

Arguments

data

a tibble with date variables admission_date and discharge_date

admission_var, discharge_var

the admission_date and discharge_date variables

earliest_date, latest_date

the earliest and latest dates (months) to compute new variables for

pivot_longer

Should the data be left in wide form or pivoted to long form (default)

Value

a tibble with new variables