Folks, I have some weekly dataseries that I convert to monthly xts (with yearmon indices), and obtain the two following extracts: > str(sig) An 'xts' object from Apr 1998 to Sep 1998 containing: Data: num [1:6, 1] 0.0083 0.2799 -0.2524 -0.0119 0.18 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr "e1" Indexed by objects of class: [yearmon] TZ: GMT xts Attributes: NULL
> str(ret) An 'xts' object from Mar 1998 to Aug 1998 containing: Data: num [1:6, 1] -0.007829 0.006452 -0.000276 -0.000644 0.002572 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr "twi.Close" Indexed by objects of class: [yearmon] TZ: GMT xts Attributes: NULL I understand that mathematical objects on xts objects will be performed only on the datapoints with common indices, in this case Apr 1998 to Aug 1998. So I do: > sig * ret Data: numeric(0) Index: NULL Which doesn't give me what I expect. However, if I do: > as.zoo(sig) * as.zoo(ret) e1 Apr 1998 5.351189e-05 May 1998 -7.716467e-05 Jun 1998 1.624531e-04 Jul 1998 -3.055679e-05 Aug 1998 4.122321e-04 Which is as I expect. I took a look at the structure of the two objects: > dput(sig) structure(c(0.00829354917358671, 0.279914830605598, -0.252440486192738, -0.0118822201758384, 0.179972233000564, -0.209066714293924), index = c(891388800, 893980800, 896659200, 899251200, 901929600, 904608000), .Dim = c(6L, 1L), .Dimnames = list(NULL, "e1"), class = c("xts", "zoo"), .indexTZ = structure("GMT", .Names = "TZ"), .indexCLASS = "yearmon") > dput(ret) structure(c(-0.00782945094736132, 0.00645222996118644, -0.000275671952124412, -0.000643530245146628, 0.00257163991836062, 0.00229053194651918 ), index = c(890784000, 893808000, 896227200, 898646400, 901670400, 904089600), .Dim = c(6L, 1L), .Dimnames = list(NULL, "twi.Close"), .indexCLASS = "yearmon", .indexTZ = structure("GMT", .Names = "TZ"), class = c("xts", "zoo")) So clearly the internal values of the supposedly overlapping parts of the indices are different, although they are both 'yearmon' and seem to represent the same months. If I do > dput(as.zoo(ret)) structure(c(-0.00782945094736132, 0.00645222996118644, -0.000275671952124412, -0.000643530245146628, 0.00257163991836062, 0.00229053194651918 ), .Dim = c(6L, 1L), .Dimnames = list(NULL, "twi.Close"), index = structure(c(1998.16666666667, 1998.25, 1998.33333333333, 1998.41666666667, 1998.5, 1998.58333333333 ), class = "yearmon"), class = "zoo") > dput(as.zoo(sig)) structure(c(0.00829354917358671, 0.279914830605598, -0.252440486192738, -0.0118822201758384, 0.179972233000564, -0.209066714293924), .Dim = c(6L, 1L), .Dimnames = list(NULL, "e1"), index = structure(c(1998.25, 1998.33333333333, 1998.41666666667, 1998.5, 1998.58333333333, 1998.66666666667), class = "yearmon"), class = "zoo") Now the indices have the expected overlaps. I'm not sure if this is a bug in xts? > sessionInfo() R version 2.9.2 (2009-08-24) i386-pc-mingw32 locale: LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] xts_0.6-7 zoo_1.5-8 svSocket_0.9-43 svMisc_0.9-48 TinnR_1.0.3 R2HTML_1.59-1 Hmisc_3.6-1 rcom_2.2-1 rscproxy_1.3-1 loaded via a namespace (and not attached): [1] cluster_1.12.0 grid_2.9.2 lattice_0.17-25 tools_2.9.2 Please advise. Thanks, Murali ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.