Diff () does not work at the zoo facility

While working on a new project in R, I wrote the following code:

sp500 <- get.hist.quote("^GSPC",start=(today <- Sys.Date())-735,quote="Cl") lsp500 <- log(sp500) rlsp500 <- diff(lsp500) 

The problem is with the diff () function, it causes the following error:

 Error in MATCH(x, x) : could not find function "MATCH" 

All other codes are executed without problems. I use RStudio and R version 2.15.2 (2012-10-26) - "Trick or Treat" on Mac OSX 10.8.2.

 > sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] tseries_0.10-30 loaded via a namespace (and not attached): [1] grid_2.15.2 lattice_0.20-10 quadprog_1.5-4 tools_2.15.2 zoo_1.7-9 

What am I missing?

+4
source share
1 answer

tseries::get.hist.quote returns the default zoo object, but the tseries package does not bind the zoo, so zoo::MATCH not found. I assume that zoo::MATCH used in diff.zoo or one of the functions it diff.zoo .

Attaching a zoo (via library(zoo) ) will fix the problem.

+7
source

All Articles