HT索引在xts时间序列对象中每个月末的RSI值

时间:2010-08-23 14:39:42

标签: r xts

首先我读入一个csv并创建一个xts对象。

require(quantmod)

sugar  <- as.xts(read.zoo("SUGAR.CSV", sep=",", format ="%m/%d/%Y", header=TRUE))

然后我使用TTR创建一系列新的RSI值(使用quantmod加载)

sugarRSI <- RSI(sugar)

现在我想获得一个新系列,其中只包含每个月最后一天的价值。 xts中有一个last()函数,但不清楚如何有效地部署它。

1 个答案:

答案 0 :(得分:2)

我认为apply.monthly(sugarRSI, last)会做你想做的事。