[R] to convert a character string in time

Gabor Grothendieck ggrothendieck at gmail.com
Wed Feb 3 15:27:43 CET 2010


Try this (and see R News 4/1):

> library(chron)
> tt <- times(paste("5:20", "00", sep = ":")); tt
[1] 05:20:00
> tt + 12/24 # add 12 hours
[1] 17:20:00

On Wed, Feb 3, 2010 at 8:27 AM, karine heerah <karine.heerah at hotmail.fr> wrote:
>
> hi,
>
>
>
> I have my data time expressed in character string exple "5:20" (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function:
>
>
>
> balise07$Hour <- as.POSXIct(balise07$Hour)
>
>
>
> but it didn't work.
>
> Do you know why? Do you know how i can convert my string character in a real time?
>
>
>
> Thanks
>
> Karine HEERAH
>
> Master 2 mention "océanographie et environnements marins", parcours océanique
>
> 42 rue Salvador Allende
> 92000 Nanterre
> 06.61.50.97.47
>
>
>
>
> _________________________________________________________________
>
>
>        [[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