[R-SIG-Finance] xts, period.apply question
Joshua Ulrich
josh.m.ulrich at gmail.com
Wed May 11 17:00:53 CEST 2011
Hi Subhrangshu,
This is a bug that was introduced when I attempted to change
period.apply to nicely handle functions that provide multi-column
output. I've patched on R-forge -- revision 593.
The R-forge servers will re-build the package soon, at which point can
install via:
R> install.packages("xts", repos="http://r-forge.r-project.org").
Thanks for the report!
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Tue, May 10, 2011 at 8:50 AM, Subhrangshu Nandi <nands31 at gmail.com> wrote:
> 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
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>
More information about the R-SIG-Finance
mailing list