library(tidyverse) main_csv <- "~/analysis_data/092925_unified_phab.csv" main_df <- read.csv(main_csv, header = TRUE) date1 <-1380499199 # 9-29-2013 date2 <- 1385510399 # 11-26-2013 date3 <-1443657599 # 09-30-2015 new_outcome <- main_df |> mutate( resolution_outcome = case_when( comment_type == "task_description" & source == "c1" & date_closed < date1 ~ TRUE, comment_type == "task_description" & source == "c1" & date_closed >= date1 ~ FALSE, comment_type == "task_description" & source == "c2" & date_closed < date2 ~ TRUE, comment_type == "task_description" & source == "c2" & date_closed >= date2 ~ FALSE, comment_type == "task_description" & source == "c3" & date_closed < date3 ~ TRUE, comment_type == "task_description" & source == "c3" & date_closed >= date3 ~ FALSE, comment_type == "task_description" & is.na(date_closed) ~ FALSE, TRUE ~ NA ) ) |> select(-closed_relevance) anyNA(new_outcome$resolution_outcome[new_outcome$comment_type == "task_description"]) write.csv(new_outcome, "100325_unified_phab.csv", row.names = FALSE)