Created
June 6, 2019 01:29
-
-
Save Dpananos/bf7ac00816a05e8d518400552f7cfcde to your computer and use it in GitHub Desktop.
Length of stay in days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(lubridate) | |
#Make fake data | |
dates2019 <- seq(ymd('2019-01-01'), ymd('2019-12-31'), by ='1 week') | |
dates2020 <- seq(ymd('2020-01-01'), ymd('2020-12-31'), by ='1 week') | |
admission <- sample(dates2019, size = 10) | |
discharge <- sample(dates2020, size = 10) | |
hospital_stays<-tibble(admission = admission, discharge = discharge) | |
#Calciulate duration in days | |
hospital_stays %>% | |
mutate(len_of_stay = as.numeric(discharge - admission, unit = 'days')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment