I have the following data frame in R:
USUBJID <- c(1, 2, 3)
EOT <- c("2021-08-17", "2020-08-10", "2020-08-10")
DTHDT <- c(NA, "2021-04-10", "2022-08-05")
EOSDT <- c("2023-08-17", "2021-04-10", "2022-08-05")
# Create DataFrame
dat<-data.frame(USUBJID=USUBJID, EOTDT=as.Date(c("2021-08-17", "2020-08-10", "2020-08-10")),
DTHDT=as.Date(c(NA, "2021-04-10", "2022-08-05`enter code here`")),
EOSDT=as.Date(c("2023-08-17", "2021-04-10", "2022-08-05")))
I would like to generate a fifth column that takes the minimum non-missing date among the 3 other dates for each USUBJID. For instance, the the first subject that would be 2021-08-17.