[R] Calculate Averages for time data

Gabor Grothendieck ggrothendieck at gmail.com
Tue Nov 3 16:45:36 CET 2009


Next time please provide sample input.

library(chron)

# input
ch <- c("02:24:00", "04:48:00", "07:12:00", "09:36:00", "12:00:00",
"14:24:00", "16:48:00", "19:12:00", "21:36:00")

# convert to times
tt <- times(ch)

# calculate mean
mean(tt)


On Tue, Nov 3, 2009 at 10:35 AM, Sunita22 <sunitap22 at gmail.com> wrote:
>
> Hello
>
> I have time data which is in hh:mm:ss format and I need to calculate
> averages for this data. I tried converting the data as integer so that I
> could calculate the average, but it doesn't serve the purpose. I tried using
> Chron package also. But I am stuck up as to how to deal with the time data.
> Please guide me as to how to deal with Time data in R.
>
> Thank you in advance
>
> Regards
> Sunita
> --
> View this message in context: http://old.nabble.com/Calculate-Averages-for-time-data-tp26160202p26160202.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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