An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110923/53217035/attachment.pl>
Error with Rollmean
5 messages · John Kerpel, Gabor Grothendieck
On Fri, Sep 23, 2011 at 12:52 PM, John Kerpel <john.kerpel at gmail.com> wrote:
I'm getting the following error with rollmean from the zoo package:
rollmean(x,k=20,align='right')Error in `colnames<-`(`*tmp*`, value = "T") :
?attempt to set colnames on object with less than two dimensions x is originally a univariate timeSeries object that is coerced to zoo via as.zoo. ?I've used this before without incident. ?What am I doing wrong? ?I'm on Windows-7 64 bit, R 64-bit v2.13.1.
We can't really tell what is wrong unless you provide a reproducible example. The following is reproducible and seems to work ok:
library(timeSeries)
Loading required package: timeDate
library(zoo)
...snip...
data(MSFT)
MSFT.zoo <- as.zoo(MSFT)
MSFT.zoo.3 <- rollmean(MSFT.zoo, 3)
packageVersion("zoo")
[1] ?1.7.4?
packageVersion("timeSeries")
[1] ?2130.92?
R.version.string
[1] "R version 2.13.1 Patched (2011-09-02 r56895)"
win.version()
[1] "Windows Vista (build 6002) Service Pack 2" Try displaying the output of dput(x) or show how to reconstruct it from scratch in a reproducible fashion.
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110923/c130d59a/attachment.pl>
On Fri, Sep 23, 2011 at 1:51 PM, John Kerpel <john.kerpel at gmail.com> wrote:
Here's an example:
library(timeSeries) library(zoo) data(MSFT) MSFT.zoo <- as.zoo(MSFT[,"Close"]) head(MSFT.zoo)
Close 2000-09-27 60.6250 2000-09-28 61.3125 2000-09-29 60.3125 2000-10-02 59.1250 2000-10-03 56.5625 2000-10-04 55.4375
MSFT.zoo.3 <- rollmean(MSFT.zoo, 3)
Error in `colnames<-`(`*tmp*`, value = "Close") : attempt to set colnames on object with less than two dimensions
Thanks. Its now fixed in the development version. Use svn version
899 or later or add this to your code:
source("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/zoo/R/rollmean.R?revision=899&root=zoo")
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
On Fri, Sep 23, 2011 at 2:01 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
On Fri, Sep 23, 2011 at 1:51 PM, John Kerpel <john.kerpel at gmail.com> wrote:
Here's an example:
?library(timeSeries) ?library(zoo) data(MSFT) MSFT.zoo <- as.zoo(MSFT[,"Close"]) head(MSFT.zoo)
? ? ? ? ? ? ?Close 2000-09-27 60.6250 2000-09-28 61.3125 2000-09-29 60.3125 2000-10-02 59.1250 2000-10-03 56.5625 2000-10-04 55.4375
MSFT.zoo.3 <- rollmean(MSFT.zoo, 3)
Error in `colnames<-`(`*tmp*`, value = "Close") : ? attempt to set colnames on object with less than two dimensions
Thanks. ?Its now fixed in the development version. ?Use svn version
899 or later or add this to your code:
source("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/zoo/R/rollmean.R?revision=899&root=zoo")
I have made one more fix so it should be svn 900 or:
source("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/zoo/R/rollmean.R?revision=900&root=zoo")
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com