Create a sequence of useful days in R

Asked

Viewed 505 times

0

I have a data frame the following columns:

Date (Only days of the week and without holidays, of several years) Month Year ... I want to create a sequence of business days. So I wanted a function that read the smallest day of the first month and the biggest day of the first month and put a sequence of 1 until the end. And repeat this for every month of my database.

Any idea??

1 answer

3

Use the package bizdays of Wilson Freitas

# install.packages('bizdays')
bizdays::bizseq('2017-01-01', '2017-01-31', cal = "Brazil/ANBIMA")

#> [1] "2017-01-02" "2017-01-03" "2017-01-04" "2017-01-05" "2017-01-06"
#> [6] "2017-01-09" "2017-01-10" "2017-01-11" "2017-01-12" "2017-01-13"
#>[11] "2017-01-16" "2017-01-17" "2017-01-18" "2017-01-19" "2017-01-20"
#>[16] "2017-01-23" "2017-01-24" "2017-01-25" "2017-01-26" "2017-01-27"
#>[21] "2017-01-30" "2017-01-31"

You can adjust calendar options by first looking at the help of this function.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.