[R] Strage result with an append/strptime combination

Gabor Grothendieck ggrothendieck at gmail.com
Wed Aug 29 14:29:41 CEST 2007


Try chron:

> library(chron)
> namefile <- "070707050642.dat"    #day-month-year-hour-minute-second.dat
> x <- chron(substr(namefile, 1, 6), substr(namefile, 7, 12),
+   format = c("dmy", "hms"), out.format = c("m/d/y", "h:m:s"))
> c(x, x)
[1] (07/07/07 05:06:42) (07/07/07 05:06:42)

See R News 4/1 Help Desk article for more.


On 8/29/07, Ptit_Bleu <ptit_bleu at yahoo.fr> wrote:
>
> Hi,
>
> I keep on trying to write some small scripts in order to learn R but even
> with basic scripts I have problems ...
>
> I start with the name of a file which is in fact the time the file has been
> generated (I cannot change the format). Then I convert namefile with
> strptime. The problem occurs when I add another time from another file with
> append. It displays some informations I don't want.
>
> I found a post about this problem
> (http://www.nabble.com/Error-with-strptime-tf3607942.html#a10081942) but I
> don't understand the solution. I tested as.POSIXct or as.POSIX.lt but it has
> no effect.
>
> Do you have some ideas to solve this problem ?
> Thank you for your help.
> Ptit Bleu.
>
> -------------------------------------------------------
>
> >namefile<-"070707050642.dat"    #day-month-year-hour-minute-second.dat
> >jourheure<-strptime(namefile,"%d%m%y%H%M%S")
>
> > jourheure
> [1] "2007-07-07 05:06:42"
>
> >jourheure<-append(jourheure,jourheure)
> > jourheure
> [1] "2007-07-07 05:06:42 Paris, Madrid (heure d'été)" "2007-07-07 05:06:42
> Paris, Madrid (heure d'été)"
>
> --
> View this message in context: http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12385852
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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