Hi, I would like to replace values of x1 column to 0 or NA if dat1 >date2 if somebody can help me. Appreciate it.
data <- data.frame(x1 = 1:10,
date1 = c("2020-01-25", "2021-02-10","2021-03-15","2020-04-09","2021-05-11","2020-06-07","2021-08-08", NA,"2020-10-18", "2021-11-11"),
x3 = c(" ", "B", "A", "F","F", " "," ", " "," "," "),
date2 = c("2021-01-25", "2022-02-10","2020-03-15","2021-04-09","2020-05-11",NA,"2020-09-08", NA,"2021-05-18", "2020-10-11"),
x4 = factor(c("B", "B", "A", "F", "A", "B", "A", "B","A", "B")),
stringsAsFactors = FALSE)