I need to get the mean of times in column "ci" [c]lock-[i]n. The data is in character format, e.g. "8:05 AM". I can use the below code to reformat and get the data to a point wherein I can compute a mean:
hrs$ci <- strptime(hrs$ci, format = "%I:%M %p")
mean(hrs$ci)
But for some reason when I try to use dcast to create a table...
hrs <- dcast(hrs, Office ~ Week, value.var = "ci", fun.aggregate = mean)
...it doesn't work and I get this error:
Error in dim(ordered) <- ns : dims [product 900] do not match the length of object [9900]
Any ideas on what I am doing wrong? Or have a suggestion for a better way? In the end I am trying to get the table that the dcast would provide with average clock-in times by week for each office.
Ideally at the end I would have the fraction of a day (i.e. 0.50 = noon) for the time, but I could probably work with alternative formats.