[R] as.POSIXct month problem
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Oct 26 22:09:20 CET 2009
guillaume chaumet wrote:
> Thank you for your quick response
>
>
>> sessionInfo()
> R version 2.9.2 (2009-08-24)
> x86_64-pc-linux-gnu
>
> locale:
> LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> I need to change fr by en?
>
Probably, since your input is in English.
However, it is still a bit puzzling. I have (on Fedora)
> x <- c("1jan1960", "2jan1960", "31mar1960", "30jui1960")
> strptime(x, "%d%b%Y")
[1] "1960-01-01" "1960-01-02" "1960-03-31" NA
> Sys.setlocale("LC_TIME","fr_FR.UTF-8")
[1] "fr_FR.UTF-8"
> strptime(x, "%d%b%Y")
[1] "1960-01-01" "1960-01-02" "1960-03-31" "1960-07-30"
> x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960")
> strptime(x, "%d%b%Y")
[1] "1960-01-01" "1960-01-02" "1960-03-31" NA
So there are understandable issues with July (and February, April, May,
and August), but I don't see any reason to get four NAs. However, you
are at the mercy of your OS's locale database (you're not saying which
OS, just that it is a linux variant).
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list