Skip to content

Commit

Permalink
adding the death dates to activity after death cases (#972)
Browse files Browse the repository at this point in the history
adding the death dates to the cases where there is activity after death

Co-authored-by: marjom02 <[email protected]>
  • Loading branch information
SwiftySalmon and marjom02 authored Jun 24, 2024
1 parent f047aab commit ce90a45
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/add_activity_after_death_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ add_activity_after_death_flag <- function(
flag_data <- flag_data %>%
dplyr::filter(.data$activity_after_death == 1) %>%
# Remove temporary flag variables used to create activity after death flag and fill in missing death_date
dplyr::select(.data$year, .data$chi, .data$record_keydate1, .data$record_keydate2, .data$activity_after_death) %>%
dplyr::select(.data$year, .data$chi, .data$record_keydate1, .data$record_keydate2, .data$activity_after_death, .data$death_date_boxi) %>%
dplyr::distinct()

# Match activity after death flag back to episode file
Expand All @@ -94,7 +94,12 @@ add_activity_after_death_flag <- function(
flag_data,
by = c("year", "chi", "record_keydate1", "record_keydate2"),
na_matches = "never"
)
) %>%
dplyr::mutate(death_date = lubridate::as_date(ifelse(is.na(death_date) & !(is.na(death_date_boxi)),
death_date_boxi, death_date
))) %>%
dplyr::select(-death_date_boxi)



return(final_data)
Expand Down

0 comments on commit ce90a45

Please sign in to comment.