Skip to content
Prev 350527 / 398503 Next

LM() and time in R

Hi Livia,
You can convert the time of day fields using strptime like this:

strptime(sapply(strsplit("time: 08:14:22"," "),"[",2),"%H:%M:%S")

This will give you the times as seconds in the current day. If you
then wish to divide the day into morning, afternoon and night, you
could create three time cutpoints, say:

strptime("06:00:00","%H:%M:%S")
strptime("12:00:00","%H:%M:%S")
strptime("20:00:00","%H:%M:%S")

such that any time less than the first or more than the third would be
night, and so on. I think it might be a good idea to factor the daily
price of crude oil (get this from the date) into the regression just
to see how much variance that explains compared to time of day
variations.

Jim

On Thu, Apr 30, 2015 at 6:06 PM, Livia Maria Vestergaard
<lvest09 at student.sdu.dk> wrote: