I have one dataset in R where I have data about the date of hospital admission and date of death.
For instance, let's take the code as -
set.seed(1)
tep <- data.frame(Date_of_birth= sample(c("11-12-1987", "11-10-1999", "19-01-1977", "20-12-1950"), 20, T),
Hospital_admission= sample(c("11-02-2019", "11-03-2019", "10-02-2019", "11-03-2019", "10-03-2019"), 20, T),
Death_date= sample(c("10-03-2019", "10-06-2019", "12-01-2020", "05-03-2019", "01-02-2020"), 20, T))
I have to calculate the date of death in three different timelines as follows-
- I need to calculate people who died 30 days, and I have to make variables with values like 1 and 0. 1= for those who died in 30 days and 0= those who did not.
- Everything is similar, here I have to calculate those who died within 6 months of hospital admission
- Again, everything is similar, here I have to calculate those who died within one year of hospital admission
Later, I have to make a table together for all these three with percentages.
In last, I need to use the gender variable to make a table with these three.
Can anyone help with this confusion? I am battering with this for a very long time.
I will be very thankful for any kind of helpful input.
