Patrick, ## Run the following script an notice the different values of the dataframe "data" in each instance.
# I understand you have done something like the following: data <- data.frame(COL1 = c("6/1/14", "7/1/14"), COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE) data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) data data$COL2 <- as.Date(as.character(data$COL2, format = "%y/%m/%d")) data$COL1 <- as.Date(as.character(data$COL1, format = "%y/%m/%d")) data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) data # What you may want instead is the following: data <- data.frame(COL1 = c("6/1/14", "7/1/14"), COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE) data ## strptime() converts the character vector to POSIXct so you do not necessarily ## need the as.Date. However, they are not the same and you may need the Date ## class. data$COL2 <- as.Date(strptime(data$COL2, format = "%m/%d/%y")) data$COL1 <- as.Date(strptime(data$COL1, format = "%m/%d/%y")) data data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) data R. Mark Sharp, Ph.D. msh...@txbiomed.org > On Aug 23, 2017, at 9:53 AM, Patrick Casimir <patrc...@nova.edu> wrote: > > data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) > > > COL1 COL2 > 6/1/14 5/1/15 > 7/1/14 5/1/15 > > > data$COL2<- as.Date(as.character(data$COL2, format="%y/%m/%d")) > data$COL1<- as.Date(as.character(data$COL1, format="%y/%m/%d")) > CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:10}} ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.