首先我读入一个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()函数,但不清楚如何有效地部署它。
答案 0 :(得分:2)
我认为apply.monthly(sugarRSI, last)
会做你想做的事。