From 12f942d0bcbb39560150de18726ed27be2e7f9f8 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 23 Jan 2023 14:40:31 -0500 Subject: [PATCH] Eagerly convert from and to data.table --- R/workpatterns_classify_bw.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/workpatterns_classify_bw.R b/R/workpatterns_classify_bw.R index 327e0106..87f067d7 100644 --- a/R/workpatterns_classify_bw.R +++ b/R/workpatterns_classify_bw.R @@ -234,7 +234,8 @@ workpatterns_classify_bw <- function(data, WpA_classify <- WpA_classify[, c("PersonId", "Date", "Active_Hours", "HourType", "sent")] %>% .[, .(sent = sum(sent)), by = c("PersonId", "Date", "Active_Hours", "HourType")] %>% - tidyr::spread(HourType, sent)%>% + dplyr::as_tibble() %>% + tidyr::spread(HourType, sent) %>% left_join(WpA_classify %>% ## Calculate first and last activity for day_span filter(sent > 0)%>% group_by(PersonId, Date)%>% @@ -242,7 +243,8 @@ workpatterns_classify_bw <- function(data, Last_signal = max(End)), by = c("PersonId","Date"))%>% mutate(Day_Span = Last_signal - First_signal, - Signals_Break_hours = Day_Span - Active_Hours) + Signals_Break_hours = Day_Span - Active_Hours) %>% + data.table::as.data.table() ## Working patterns classification ---------------------------------------