Dear R fellows,

I created a new column Date_flag to compare the dates of COL1 and COL2 using 
the code
below. But it showed that 5/1/15 is greater than 6/1/2014 and 5/1/2015 greater 
than
7/1/2014 despite the year is greater. How do I fix that? I did try to format as 
%y/%m/%d

 but it does not fix that.


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"))


        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to