I'm trying to reshape my dataframe, but some of the fields have multiple results:
input = structure(list(Employee = structure(c(4L, 5L, 7L, 2L, 2L, 4L,
6L, 2L, 3L, 8L, 8L, 1L, 7L, 2L), .Label = c("Arty", "Chumlee",
"Francis", "John", "Randy", "Sara", "Tania", "Tony"), class = "factor"),
Workday = structure(c(2L, 2L, 2L, 2L, 2L, 7L, 8L, 6L, 1L,
4L, 4L, 3L, 5L, 5L), .Label = c("Friday", "Monday", "Satuday",
"Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = "factor"),
Start = structure(c(6L, 1L, 6L, 2L, 4L, 6L, 1L, 2L, 5L, 7L,
3L, 1L, 6L, 1L), .Label = c("10:00", "10:30", "12:30", "15:00",
"8:30", "9:00", "9:30"), class = "factor"), Finish = structure(c(4L,
5L, 4L, 2L, 7L, 4L, 5L, 2L, 6L, 1L, 8L, 3L, 4L, 5L), .Label = c("12:00",
"12:30", "14:45", "15:00", "16:00", "16:30", "17:00", "20:00"
), class = "factor")), class = "data.frame", row.names = c(NA,
-14L))
and I'm trying to make an output that looks like this:
output = structure(list(Employee = structure(c(5L, 6L, 3L, 7L, 4L, 9L,
2L, 8L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Arty", "Chumlee",
"Francis", "John", "Randy", "Sara", "Tania", "Tony"), class = "factor"),
Monday = structure(c(4L, 2L, 3L, 1L, 1L, 1L, 1L, 4L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = c("", "10:00 - 16:00", "10:30 - 12:30; 15:00 - 17:00",
"9:00 - 15:00"), class = "factor"), Tuesday = structure(c(2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("",
"9:00 - 15:00"), class = "factor"), Wednesday = structure(c(1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("",
"10:00 - 16:00"), class = "factor"), Thursday = structure(c(1L,
1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("",
"10:30 - 12:30"), class = "factor"), Friday = structure(c(1L,
1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("",
"8:30 - 16:30"), class = "factor"), Saturday = structure(c(1L,
1L, 1L, 1L, 1L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("",
"10:00 - 14:45", "9:30 - 12:00; 12:30 - 20:00"), class = "factor"),
Sunday = structure(c(1L, 1L, 2L, 1L, 1L, 1L, 1L, 3L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = c("", "10:00 - 16:00", "9:00 - 15:00"
), class = "factor")), class = "data.frame", row.names = c(NA,
-14L))
The difficultly I'm having is that some employees do two shifts a day (eg. Chumlee), and I'd like to truncate that into one field.
I've no idea how to keep the data, and don't know if it's best to join the open and close first, and then try and reshape it?