如何计算两个日期之间的工作日,以删除并行实例和Bhols(网络日)

时间:2018-09-05 12:32:01

标签: date dataframe days

我试图找到一个可以从开始日期和结束日期得出工作日(-bhols)的函数或逻辑,但是首先要进行排序以删除相同订单的重叠日期范围,最终结果是按订单分组下面的每个示例(适用于数据框)

  • “工作日”是用Excel制作的,用于演示,数据框具有顺序,开始,结束。

enter image description here

# 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))

0 个答案:

没有答案