[R] How do I use as.Date when day values are missing?

From: Anupa Fabian <anupa.fabian_at_yahoo.com>
Date: Sun, 24 Feb 2008 18:00:57 -0800 (PST)


I have a data frame which contains some valuable date information. But for a few of the dates, the day information missing .

Viz:
> interesting.data$date

[1] "1/22/93" "1/22/93" "1/23/93" "1/00/93" "1/28/93" "1/31/93" "1/12/93"

i.e. for dates where the day info is missing, the "%d" part of the "%m/%d/%yy" format is simply represented as "00".

When I apply as.Date to the date information, the dates which don't contain exact day information are converted to "NA".

Viz:
> as.Date(interesting.data$date)

[1] "1993-01-22" "1993-01-22" "1993-01-23" NA "1993-01-28" "1993-01-31" "1993-01-12"

Is there a way of using the as.Date function when I only have partial dates (eg missing day information which is represented as "00", as above) such  that the date isn't represented as NA?

Thanks,
Anupa



Never miss a thing. Make Yahoo your home page.

        [[alternative HTML version deleted]]



R-help_at_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. Received on Mon 25 Feb 2008 - 02:03:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Feb 2008 - 03:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive