Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R time series data, daily only working days

Tags:

date

r

sequence

I am using the following code:

dates<-seq(as.Date("1991/1/4"),as.Date("2010/3/1"),"days")

However, I would like to only have working days, how can it be done? (Assuming that 1991/1/4 is a Monday, I would like to exclude: 1991/6/4 and 1991/7/4. And that for each week.)

Thank you for your help.

like image 528
BrunoGG Avatar asked Dec 01 '22 22:12

BrunoGG


1 Answers

Would this work for you? (note, it requires the timeDate package to be installed)

# install.packages('timeDate')
require(timeDate)

# A ’timeDate’ Sequence
tS <- timeSequence(as.Date("1991/1/4"), as.Date("2010/3/1"))
tS

# Subset weekdays
tW <- tS[isWeekday(tS)]; tW
dayOfWeek(tW)
like image 131
Eric Fail Avatar answered Dec 04 '22 01:12

Eric Fail