[R] as.POSIXct month problem

William Dunlap wdunlap at tibco.com
Mon Oct 26 21:39:19 CET 2009


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




More information about the R-help mailing list