我正在尝试按相对员工寿命计算利用率。我需要在记录时间的最早日期和最远日期之间分配该员工可用的总小时数。从那里我将使用它作为利用率=工作时间/总时间的除数。
在测试 bizdays 功能时,我尝试了一个简单的例子。
bizdays::bizdays("2020-02-07","2020-02-14")
[1] 7
函数没有返回正确的工作日数的任何原因?我预计 5 个工作日,因为 2/07 是星期五,所以应该只包括 1 周。
目标是在以下函数中使用 bizdays,该函数将应用于带有 gapply 的分组 df。
timeentry = function(x){
end_date = max(x$terminus)#creates an end_date variable from further end date in the group
start_date = min(x$onset) #creates a start_date from earliest start date in the group
start_date %>% bizdays(end_date) * 8 #subtracts dates and multiple by 8 to get work hours between two dates
}
我将以这种方式应用该功能。不幸的是,它返回一个错误,提示它无法分配大小为 4687 gb 的向量。这是一个单独的问题,我希望有人能指出。
util = group %>% gapply(.,timeentry)
其中 group 是分组的 df。