Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0903310036y1bf4a18fh2fe9ddf66396cced@mail.gmail.com>
Date: 2009-03-31T07:36:03Z
From: Gabor Grothendieck
Subject: Convert Character to Date
In-Reply-To: <662076.42273.qm@web112213.mail.gq1.yahoo.com>

The yearmon class in the zoo package can represent year/months:

> library(zoo)
> ym <- as.yearmon("1990-January", "%Y-%B"); ym
[1] "Jan 1990"
> as.Date(ym)
[1] "1990-01-01"


On Tue, Mar 31, 2009 at 3:14 AM, Bob Roberts <quagmire54321 at yahoo.com> wrote:
> Hello,
> ? I have a date in the format Year-Month Name (e.g. 1990-January) and R classes it as a character. I want to convert this character into a date format, but when I try as.Date(1990-January, "%Y-%B"), I get back NA. The function strptime also gives me NA back. Thanks.
>
>
>
>
> ? ? ? ?[[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.
>