【发布时间】:2015-02-01 23:38:21
【问题描述】:
我想创建一个为期 14 年的 6 个月间隔向量。目的是我必须使用 PerformanceAnalytics 保存一些图:更具体地说:charts.PerformanceSummary() 每六个月。我不想手动输入每 6 个月的范围,而是想创建一个带有日期的向量,以便我可以使用循环来促进该过程。
我希望向量包含从 01-01-2000 到 12-31-2014 的日期,格式如下:
DATES
"200001/200006"
"200007/200012"
"200101/200106"
"200107/200112"
"200201/200206"
"200207/200212"
...
"201407/201412"
但是我不知道该怎么做!
例如:
library(PerformanceAnalytics)
# Load DATA "edhec"
data(edhec)
# Now I can view the chart from "01-01-1999" to "06-30-1999"
charts.PerformanceSummary(edhec[,1]["199901/199906"])
但如果我有 DATES 向量,我可以执行以下操作:
# Save formatted dates to "DATES"
DATES <- c("200001/200006","200007/200012")
# Plot Selected Dates only
charts.PerformanceSummary(edhec[DATES[1]])
# OR:
charts.PerformanceSummary(edhec[DATES[2]])
感谢任何帮助!!!
【问题讨论】: