Hi Simon,

The problem with as.Date is more complicated than I thought as even  
with my system set to French (not Canadian French),  I can easily  
crash R (even the latest patched version from today) every single time  
in a new session with this simple code:

french.dates <- c("7-déc-07",  "11-déc-07", "14-déc-07", "18-déc-07",  
"21-déc-07", "24-déc-07", "26-déc-07", "28-déc-07", "31-déc-07", "2- 
jan-08",  "4-jan-08",  "7-jan-08", "9-jan-08", "11-jan-08", "14- 
jan-08", "16-jan-08", "18-jan-08", "21-jan-08", "23-jan-08", "25- 
jan-08", "28-jan-08")

as.Date(french.dates, "%d-%b-%y")

As you'll see below, this is in a brand new R session. I have  
restarted R up to 5 times, this always crashes it. I give you  
sessionInfo below.

But if I run this modified version, it works:

 > french.dates <- c("7-déc-07",  "11-déc-07", "14-déc-07", "18- 
déc-07", "21-déc-07", "24-déc-07", "26-déc-07", "28-déc-07", "31- 
déc-07", "2-jan-08",  "4-jan-08",  "7-jan-08", "9-jan-08", "11- 
jan-08", "14-jan-08", "16-jan-08", "18-jan-08", "21-jan-08", "23- 
jan-08", "25-jan-08", "28-jan-08")
 >
 > as.Date(french.dates)
Erreur dans fromchar(x) :
   la chaîne de caractères n'est pas dans un format standard non ambigu
 >
 > as.Date(french.dates, "%d-%b-%y")
  [1] "2007-12-07" "2007-12-11" "2007-12-14" "2007-12-18" "2007-12-21"
  [6] "2007-12-24" "2007-12-26" "2007-12-28" "2007-12-31" "2008-01-02"
[11] "2008-01-04" "2008-01-07" "2008-01-09" "2008-01-11" "2008-01-14"
[16] "2008-01-16" "2008-01-18" "2008-01-21" "2008-01-23" "2008-01-25"
[21] "2008-01-28"

Cheers,

Denis



R version 2.6.2 RC (2008-01-30 r44258)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.

R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.

Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.

 > sessionInfo()
R version 2.6.2 RC (2008-01-30 r44258)
i386-apple-darwin9.1.0

locale:
fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
 > french.dates <- c("7-déc-07",  "11-déc-07", "14-déc-07", "18- 
déc-07", "21-déc-07", "24-déc-07", "26-déc-07", "28-déc-07", "31- 
déc-07", "2-jan-08",  "4-jan-08",  "7-jan-08", "9-jan-08", "11- 
jan-08", "14-jan-08", "16-jan-08", "18-jan-08", "21-jan-08", "23- 
jan-08", "25-jan-08", "28-jan-08")
 >
 > as.Date(french.dates, "%d-%b-%y")

  *** caught bus error ***
address 0x8, cause 'non-existent physical address'

Traceback:
  1: strptime(x, format)
  2: as.Date.character(french.dates, "%d-%b-%y")
  3: as.Date(french.dates, "%d-%b-%y")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace



Le 31 janv. 08 à 13:33, [EMAIL PROTECTED] a écrit :

> Message: 3
> Date: Thu, 31 Jan 2008 13:33:03 -0500
> From: Simon Urbanek <[EMAIL PROTECTED]>
> Subject: Re: [R-SIG-Mac] R crashes with french canadian OS X format
>       (was:   [R] dates in French format)
> To: Denis Chabot <[EMAIL PROTECTED]>
> Cc: Gabor Grothendieck <[EMAIL PROTECTED]>,
>       [email protected]
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes
>
> Denis,
>
> thanks for the report. It should be now fixed in R-patched and R- 
> devel.
>
> Cheers,
> Simon
>
>


        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to