[R-SIG-Finance] apply.fromstart() warnings
Gabor Grothendieck
ggrothendieck at gmail.com
Mon Jun 2 14:27:56 CEST 2008
To do it in zoo alone try this:
library(zoo)
d <- zoo(matrix(1:50, 25), as.Date(1:25))
dd <- NA * d
for(i in 21:nrow(dd)) dd[i, ] <- colMeans(d[1:i, ])
You also might try updating the to latest version of all packages and R
although that does not appear to be the source of the problem here.
On Mon, Jun 2, 2008 at 7:57 AM, Murali Menon <feanor0 at hotmail.com> wrote:
>
>
> Folks,
>
> When I attempt to find the growing window columnwise mean of a two-dimensional array, I get a bunch of warnings. Any idea why? Here's my code:
>
>> library(PerformanceAnalytics)
>
>> d <- zoo(matrix(rnorm(50), ncol=2), order.by=as.Date(1:25))
>
>> apply.fromstart(d, gap=20, FUN="mean")
> 1970-01-02 NA NA
> 1970-01-03 NA NA
> 1970-01-04 NA NA
> 1970-01-05 NA NA
> 1970-01-06 NA NA
> 1970-01-07 NA NA
> 1970-01-08 NA NA
> 1970-01-09 NA NA
> 1970-01-10 NA NA
> 1970-01-11 NA NA
> 1970-01-12 NA NA
> 1970-01-13 NA NA
> 1970-01-14 NA NA
> 1970-01-15 NA NA
> 1970-01-16 NA NA
> 1970-01-17 NA NA
> 1970-01-18 NA NA
> 1970-01-19 NA NA
> 1970-01-20 NA NA
> 1970-01-21 -0.05899970 -0.05899970
> 1970-01-22 -0.05882669 -0.05882669
> 1970-01-23 -0.08635806 -0.08635806
> 1970-01-24 -0.15848480 -0.15848480
> 1970-01-25 -0.13168358 -0.13168358
> 1970-01-26 -0.17101046 -0.17101046
> There were 12 warnings (use warnings() to see them)
>
>
> When I check the warnings(), here's the first string I get:
>
> 1: In column.Return.calc[i] = apply(as.matrix(data.zoo[, ... :
> number of items to replace is not a multiple of replacement length
>
> I'm not sure why this should be the case?
>
>
> I'm using:
>
>> packageDescription("zoo")$Version
> [1] "1.4-2"
>> packageDescription("PerformanceAnalytics")$Version
> [1] "0.9.6"
>
>
> And R 2.6.1 on Windows XP.
>
>
> Thanks,
>
>
> Murali
>
> _________________________________________________________________
> Give to a good cause with every e-mail. Join the i'm Initiative from Microsoft.
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
More information about the R-SIG-Finance
mailing list