For a sample dataframe:
light <- structure(list(daylight.hours = structure(c(62L, 22L, 60L, 58L,
34L, 37L), .Label = c("07:12:05", "07:14:41", "07:18:24", "07:28:59",
"07:31:07", "07:45:51", "07:48:08", "07:51:29", "07:52:06", "07:58:18",
"08:01:16", "08:07:25", "08:10:08", "08:18:16", "08:23:33", "08:27:03",
"08:30:36", "08:34:13", "08:41:35", "08:46:01", "08:53:52", "08:54:17",
"09:31:16", "09:35:29", "09:39:44", "10:27:19", "10:31:45", "10:36:12",
"11:53:41", "12:11:39", "12:16:10", "12:20:23", "12:34:10", "14:18:26",
"14:22:41", "14:26:55", "14:35:21", "14:39:49", "14:44:00", "14:48:09",
"14:54:29", "14:59:08", "15:03:18", "15:11:01", "15:15:38", "15:15:52",
"15:19:09", "15:58:22", "16:07:10", "16:08:33", "16:24:12", "16:27:14",
"16:42:57", "16:55:32", "16:57:52", "17:00:06", "17:02:15", "17:03:49",
"17:04:17", "17:05:24", "17:06:14", "17:06:53", "17:08:05", "17:09:38",
"17:11:04", "17:12:24", "17:13:26", "17:13:47", "17:14:22", "17:14:32",
"17:14:42", "17:14:44", "17:15:39", "17:15:40", "17:16:22", "17:16:51",
"17:17:55"), class = "factor"), school.id = c(4L, 4L, 4L, 4L,
14L, 14L)), .Names = c("daylight.hours", "school.id"), row.names = c(NA,
6L), class = "data.frame")
I want to create another variable called d.daylight to change the daylight hours variable to a decimal. (i.e. 18:30:00 would read 18.5)
When I use the following it automatically puts todays date which is not what I am after (everything is under 24 hours).
light$d.daylight <- as.POSIXlt(light$daylight.hours, format="%H:%M:%S")
Could anyone advise me how to rectify this?