[R-SIG-Finance] xts, period.apply question

Subhrangshu Nandi nands31 at gmail.com
Tue May 10 15:50:50 CEST 2011


Is anyone else having issues with the latest update of xts and/or zoo? Some
of my functions that use *apply.weekly* or *apply.daily* are not working any
more. I'm attaching a sample dataset to help you replicate the error. Below
is a copy of my RConsole:

*> str(Data.xts)*
An ‘xts’ object from 2010-03-23 04:20:00 to 2011-05-06 15:10:00 containing:
  Data: num [1:17902, 1:2] 1508 1508 1507 1507 1506 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:2] "Close" "Close.1"
  Indexed by objects of class: [POSIXt,POSIXct] TZ:
  Original class: 'data.frame'
  xts Attributes:
List of 2
 $ tclass   : chr [1:2] "POSIXt" "POSIXct"
 $ na.action:Class 'omit'  atomic [1:1] 1
  .. ..- attr(*, "index")= num 1.27e+09
*> head(Data.xts)*
                       Close Close.1
2010-03-23 04:20:00 1507.750  537.75
2010-03-23 04:30:00 1507.875  538.50
2010-03-23 04:40:00 1506.875  538.25
2010-03-23 04:50:00 1507.000  538.00
2010-03-23 05:00:00 1506.500  538.00
2010-03-23 05:10:00 1506.500  538.00
*> fn_checkApply*
*function(Data=Data_D){*
*
*
*        MaxDiff <- max(Data[,1]) - max(Data[,2])*
*        return(MaxDiff)*
*}*
*> apply.daily(x=Data.xts, FUN=fn_checkApply)*
*Error in dimnames(x) <- dn : *
*  length of 'dimnames' [2] not equal to array extent*
*> traceback()*
*3: `colnames<-`(`*tmp*`, value = c("Close", "Close.1"))*
*2: period.apply(x, ep, FUN, ...)*
*1: apply.daily(x = Data.xts, FUN = fn_checkApply)*


Any help would be greatly appreciated. Everything was working fine until I
updated the packages on 05/02.
-- 
I'm a great believer in luck, and I find the harder I work the more I have
of it.  ~Thomas Jefferson

Subhrangshu Nandi
Algorithmic Stat-Arb Trader
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110510/b590acc6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Data.RData
Type: application/octet-stream
Size: 101911 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110510/b590acc6/attachment.obj>


More information about the R-SIG-Finance mailing list