[R] as.Data with minutes resolution

Gabor Grothendieck ggrothendieck at gmail.com
Mon Nov 10 13:50:35 CET 2008


You can use chron:

   library(chron)
   time1 <- c("03/08/08-11:00","03/08/08-11:10")
   diff(as.chron(time1, "%d/%m/%y-%H:%M"))

Also you can use POSIXct but in that case be careful
about time zones.  See R News 4/1.

On Mon, Nov 10, 2008 at 7:38 AM, Ronaldo Reis-Jr. <chrysopa at gmail.com> wrote:
> Hi,
>
> I have a vetor os dates with day and hour:minutes.
>
>> time1 <- c("03/08/08-11:00","03/08/08-11:10")
>> time1 <- as.Date(time1,"%d/%m/%y-%R")
>> summary(time1)
>        Min.      1st Qu.       Median         Mean      3rd Qu.
> Max.
> "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03"
> "2008-08-03"
>> time1[2]-time1[1]
> Time difference of 0 days
>
> I need to get the difference between these minutes, my expected result in
> this operation is 10 minutes.
>
> How I make this in R?
>
> Thanks
> Ronaldo
>
>        [[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