Skip to content

Instantly share code, notes, and snippets.

@gabrielburcea
Created August 22, 2018 14:54
Show Gist options
  • Save gabrielburcea/7f7982260ea4522564af419d4d3c89d1 to your computer and use it in GitHub Desktop.
Save gabrielburcea/7f7982260ea4522564af419d4d3c89d1 to your computer and use it in GitHub Desktop.
Calculate the Length of stay
############################
# calculating total time by using difftime - length of stay
################################
dt_los <- dt_subset %>%
mutate(LOS = as.numeric(difftime(end_datetime, start_datetime, units = c("days")))) %>% # or minutes?
select(pat_code, LOS, admission.type, disch.ward.type) %>%
na.omit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment