On Fri, 2011-09-02 at 13:00 +0200, Dean Marks wrote:
I'm having the following issue:
require( PerformanceAnalytics )
data( managers )
#This works fine:
x <- managers[ , "SP500 TR"]
apply.rolling( x , width = 6 )
#This produces an error (presumably due to indexes being empty)
x[] <- NA
apply.rolling( x , width = 6 )
### ?Error in xts(, order.by = time(R)) :
### ?order.by requires an appropriate time-based object
Is this the expected behavior? How would I avoid the error without
having to check for the special case(s)?
Well, the xts error says it all in this case. ?You don't have a time
series to roll *on*. ?This is a time series function, so without a time
series, it simply won't work.
There is the newer function rollapply.xts, but I don't recall offhand
whether it has been exported yet, or rollapply (in zoo) which is less
fussy about the 'time series' part, though it does of course assume the
ordered observations from which zoo takes its name.