Skip to content
Prev 300315 / 398503 Next

histogram of time-stamp data

Hello,

That's not the error I've had. You must be aware that read.table creates 
a data.frame and therefore the object 'timestamps' is NOT holding time 
stamps, it's holding a vector, 'V1', of time stamps.


timestamps <- read.table(text="
12:19:00
09:30:00
16:56:00
01:56:00
10:44:00
10:31:00
02:14:00
05:05:00
12:52:00
21:50:00
", stringsAsFactors=FALSE)
str(timestamps)

timestamps <- as.POSIXct(timestamps$V1, format="%H:%M:%S")  # here

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)


And the rest works.

Rui Barradas

Em 17-07-2012 07:11, e-letter escreveu: