Hi,

I have the following issue. The dataframe  df has a column (Date1) supposed
to be a date but read as a factor. There are two types of values in the
same column Date1
Type 1 are datetime like "5/23/2008 0:00:00"
Type 2 have no time like "1/10/13".

When I apply the following to the date column
df$Date1<-as.POSIXct(as.character(df$Date1, format = "%d/%m/%Y"))

For type 1 I got the expected result: "2008-05-23"
For type 2 I got NA.

I have searched but could not solve it. Please help.

Thanks,
Yolande

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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