我试图找到一个可以从开始日期和结束日期得出工作日(-bhols)的函数或逻辑,但是首先要进行排序以删除相同订单的重叠日期范围,最终结果是按订单分组下面的每个示例(适用于数据框)
# Test Function
test <- Vectorize(
function(a, b)
{
seq(a, b, by = "days")
})
# Data Frame
order <- c("CFM8" ,"CFM8","CFM8" ,"CFM8", "CFQ3","CFQ3","CFQ3")
start <- c("2018/01/01","2018/01/08","2018/01/02","2018/01/15","2018/03/01","2018/03/05","2018/03/21")
end <- c("2018/01/10","2018/01/12","2018/01/06","2018/01/30","2018/03/31","2018/03/17","2018/03/31")
df <- data.frame(order,start,end) %>%
mutate(start = ymd(start), end = ymd(end))
# Apply Function
df %>%
mutate(wd = test(start,end))