[R] Time Series

Andrew Choens andy.choens at gmail.com
Thu Jan 15 16:01:27 CET 2009


If I want to make a numerical series, I can do so easily with:

	series.numbers <- 1:10

But, I don't seem to be able to do the same with time. I want to create
a vector with 480 points that corresponds to the 480 minutes in a 8 hour
work day. Thus I want series.time to look something like this:

9:00
9:01
9:02
9:03
etc.

Last night I managed to build this by concatenating a series of strings,
and converting them to datetime format with as.Date() or strptime(), but
my method seems overly complex.

        hour <- 0:59
        day <- c(9, 10, 11, 12, 13, 14, 15, 16)
        hours <- c(rep(9, 60), rep(10, 60), rep(11, 60), rep(12, 60),   
                 rep(1, 60), rep(2, 60), rep(3, 60), rep(4, 60))
        one.day <- paste(hours, ":", hour, sep = "")
        strptime(one.day, "%H:%M")
        # OR
        # as.Date(one.day, "%H:%M")



Is there any way to do something similar to:
        strptime("09:00", "%H:%M") : strptime("11:00", "%H:%M")

When I try this, I get the following error:
	numerical expression has 9 elements: only the first used

Thanks.
--andy

-- 
Insert something humorous here.  :-)




More information about the R-help mailing list