Series names not used by stats:::acf when fUtilities (as.matrix.ts seems to be the culprit) is loaded
Pfaff, Bernhard Dr.
Bernhard_Pfaff at fra.invesco.com
Wed Dec 10 12:35:01 CET 2008
Dear Rmetrics-core member (probably Diethelm and Yohan),
I detected the following behaviour when the package "fUtilities" is
loaded:
> search()
[1] ".GlobalEnv" "package:MASS" "package:stats"
[4] "package:graphics" "package:datasets" "package:fortunes"
[7] "package:utils" "package:grDevices" "package:methods"
[10] "Autoloads" "package:base"
>
> data(EuStockMarkets)
> [1] "DAX" "SMI" "CAC" "FTSE"
> tmp.mts <- diff(log(EuStockMarkets)) * 100
> colnames(tmp.mts)
> acf(tmp.mts)
## in acf the colnames are preserved in the plot
> search()
[1] ".GlobalEnv" "package:MASS" "package:stats"
[4] "package:graphics" "package:datasets" "package:fortunes"
[7] "package:utils" "package:grDevices" "package:methods"
[10] "Autoloads" "package:base"
> colnames(tmp.mts)
[1] "DAX" "SMI" "CAC" "FTSE"
> library(fUtilities)
Rmetrics Package fUtilities (270.75) loaded.
> search()
[1] ".GlobalEnv" "package:fUtilities" "package:MASS"
[4] "package:stats" "package:graphics" "package:datasets"
[7] "package:fortunes" "package:utils" "package:grDevices"
[10] "package:methods" "Autoloads" "package:base"
> acf(tmp.mts)
## in acf the colnames are not any longer preserved!
## due to as.matrix.ts() in fUtilities
as.matrix.ts <-
function (x, ...)
{
ans = as.matrix.default(unclass(x))
attr(ans, "tsp") <- NULL
rownames(ans) <- NULL
colnames(ans) <- NULL
ans
}
and in stats:::acf you will find the line:
x <- as.matrix(x)
which make use of as.matrix.ts (S3-method dispatch) in fUtilities and
there the colnames are set to NULL.
Hence, would it be possible to alter as.matrix.ts() to something like:
as.matrix.ts <- function (x, ...)
{
ans = as.matrix.default(unclass(x))
attr(ans, "tsp") <- NULL
rownames(ans) <- NULL
ifelse(is.null(colnames(ans)), colnames(ans) <- NULL, colnames(ans)
<- colnames(x))
ans
}
or rename as.matrix.ts() such that it is not dispatched as method in
acf()? However, I do not know if the former suggested function body
change would cause trouble elsewhere.
Best,
Bernhard
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 8.0
year 2008
month 10
day 20
svn rev 46754
language R
version.string R version 2.8.0 (2008-10-20)
*****************************************************************
Confidentiality Note: The information contained in this ...{{dropped:10}}
More information about the Rmetrics-core
mailing list