i have a DF like this:
structure(list(TBOutcomeDate = c("NULL", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"
), DateOfBirth = c("2003-02-11", "1978-08-25", "1975-06-28",
"1983-01-03", "1959-08-10", "1955-07-28", "1998-12-26", "1972-03-27",
"1961-04-19", "1982-10-15", "1985-06-27", "1963-03-28", "1945-10-14",
"1985-12-14", "1985-03-22", "1953-12-27", "1990-03-18", "2021-08-01",
"1979-06-04", "2005-04-30"), FirstVisitDate = c("NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "2017-01-30", "NULL",
"2018-11-06", "2018-01-24", "NULL", "NULL", "NULL", "NULL", "NULL",
"2018-07-02", "NULL", "NULL", "NULL"), Counselling1 = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), Counselling2 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Counselling3 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), CounsellingS = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), PapSmearDate = c("NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL", "2006-04-18", "NULL"), COTStartedDate = c("NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"2006-07-24", "NULL"), SecondLineDate = c("NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL"), OutcomeDate = c("NULL", "NULL", "2019-09-20", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "2019-01-25", "NULL", "2006-09-23",
"NULL")), row.names = c(NA, 20L), class = "data.frame")
I want to declare dates as follows:
Cohort_SDate <- ymd("2023/01/01")
Cohort_EDate <- ymd("2023/03/31")
And filter somewhere in the script like:
IPTLIst <- subset(EX, IPTStartDate >= Cohort_SDate & IPTStartDate <= Cohort_EDate)
But I get an error as follows:
Error in charToDate(x) :
character string is not in a standard unambiguous format
Could I get an assistance on this. I just do not want to type dates over and over again