Hi everybody
When I try example of strptime
x <- c("1jan1960", "2jan1960", "31mar1960",
"30jul1960")
z <- strptime(x, "%d%b%Y")
The result is;
> z
[1] NA NA NA NA
I have got the same result with complete form of month but not with numeric
form.
Any idea?
[[alternative HTML version deleted]]
Not able to replicate:
x <- c("1jan1960", "2jan1960", "31mar1960",
"30jul1960")
z <- strptime(x, "%d%b%Y")
z
[1] "1960-01-01 CST" "1960-01-02 CST" "1960-03-31
CST" "1960-07-30 CDT"
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at
r-project.org]
> On Behalf Of guillaume chaumet
> Sent: Monday, October 26, 2009 3:32 PM
> To: r-help at r-project.org
> Subject: [R] as.POSIXct month problem
>
> Hi everybody
> When I try example of strptime
> x <- c("1jan1960", "2jan1960",
"31mar1960", "30jul1960")
> z <- strptime(x, "%d%b%Y")
>
> The result is;
>
> > z
> [1] NA NA NA NA
>
> I have got the same result with complete form of month but not with
> numeric
> form.
>
> Any idea?
>
> [[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.
> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of guillaume chaumet > Sent: Monday, October 26, 2009 1:32 PM > To: r-help at r-project.org > Subject: [R] as.POSIXct month problem > > Hi everybody > When I try example of strptime > x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960") > z <- strptime(x, "%d%b%Y") > > The result is; > > > z > [1] NA NA NA NA > > I have got the same result with complete form of month but > not with numeric > form.If you are not in an English 'locale' you may have to set your locale to English. E.g., on Windows: > Sys.setlocale(locale="French") [1]"LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETAR Y=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252" > strptime(x, "%d%b%Y") [1] NA NA NA NA > Sys.setlocale(locale="English") [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252" > strptime(x, "%d%b%Y") [1] "1960-01-01" "1960-01-02" "1960-03-31" "1960-07-30" Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com> > Any idea? > > [[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. >
Hi Guillaume, What is your sessionInfo() ? It works me:> x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960") > z <- strptime(x, "%d%b%Y") > z[1] "1960-01-01" "1960-01-02" "1960-03-31" "1960-07-30"> sessionInfo()R version 2.9.2 RC (2009-08-23 r49375) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base HTH, Jorge On Mon, Oct 26, 2009 at 4:31 PM, guillaume chaumet <> wrote:> Hi everybody > When I try example of strptime > x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960") > z <- strptime(x, "%d%b%Y") > > The result is; > > > z > [1] NA NA NA NA > > I have got the same result with complete form of month but not with numeric > form. > > Any idea? > > [[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. >[[alternative HTML version deleted]]