R时间序列数据,每天只有工作日 [英] R time series data, daily only working days

查看:1027
本文介绍了R时间序列数据,每天只有工作日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码:

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

然而,我只想有工作日,怎么办?
(假设1991/1/4是星期一,我想排除:1991/6/4和1991/7/4。
每周)。

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

感谢您的帮助。

推荐答案

这是否适合您? (请注意,它需要安装timeDate包)

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)

这篇关于R时间序列数据,每天只有工作日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆