[R] histogram of time-stamp data

Rui Barradas ruipbarradas at sapo.pt
Mon Jul 16 11:48:39 CEST 2012


Hello,

Try the following.


timestamps <- as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)

h1 <- cut(timestamps, breaks="hour")
h2 <- cut(timestamps, breaks="15 mins")

op <- par(mfrow=c(1, 2))
hist(as.integer(h1))
hist(as.integer(h2))
par(op)


Hope this helps,

Rui Barradas

Em 16-07-2012 09:47, e-letter escreveu:
> Readers,
>
> A data set consists of time-stamp values:
>
> 00:00:00
> 23:11:00
> 06:22:00
>
> The data set was imported:
>
> timestamps<-read.table("path/to/timestampsvalues")
> hist(timestamps)
>
> ...error... x must be numeric
>
> Then tried:
>
> plot(timestamps).
>
> How to adjust the graph to create a histogram where the intervals
> ranges can be specified, e.g. intervals of 60 minutes?
>
> Thanks in advance.
>
> ______________________________________________
> 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