[R] Locale problems with strptime to convert dates

Luis Torgo ltorgo at liacc.up.pt
Tue Dec 11 11:14:49 CET 2001

Hi. I've already posted this question 2 months ago but as I've got no
answer I've decided to try again :-)

I'm using R1.3.1 on a x86 machine running Win 2000.

My problem: I want to convert a string to a date format using strptime.

As I'm from Portugal my locale information is the following:

> Sys.getlocale()


If I do the following everything works fine :

> k <- "25-Set-01"
> strptime(k,"%d-%b-%y")
[1] "2001-09-25"

because the month September in Portuguese is named "Setembro" and thus
abbreviated as "set" and not "sep" as in English.

However, I'm interested in reading English dates. I was hoping that the
following would solve my problem:

> Sys.setlocale("LC_TIME", locale="USA")
[1] "English_United States.1252"

However, I get the following error :

> k <- "25-Sep-01"
> strptime(k,"%d-%b-%y")
[1] "NA"

Thank you in advance for any help with this,
Luis Torgo

Luis Torgo
    FEP/LIACC, University of Porto   Phone : (+351) 22 607 88 30
    Machine Learning Group           Fax   : (+351) 22 600 36 54
    R. Campo Alegre, 823             email : ltorgo at liacc.up.pt
    4150 PORTO   -  PORTUGAL         WWW   : http://www.liacc.up.pt/~ltorgo

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list