Skip to content

Commit

Permalink
Warn when quantmod:::as.zoo.data.frame() is called
Browse files Browse the repository at this point in the history
See commit 9343d9a. See #414.
  • Loading branch information
joshuaulrich committed Mar 4, 2024
1 parent 5d13057 commit fb9c89c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
37 changes: 13 additions & 24 deletions R/quantmod.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,22 @@ function(x)
`as.zoo.data.frame`<-
function(x,row.date=TRUE,...)
{
# Registered S3 method overwritten by 'quantmod':
# method from
# as.zoo.data.frame zoo
send.message <- getOption("quantmod.deprecate.as.zoo.data.frame", NULL)
if(is.null(send.message)) {
# Only message once if user hasn't set an option value
send.message <- TRUE
options(quantmod.deprecate.as.zoo.data.frame = FALSE)
}
if(isTRUE(send.message)) {
message(
"\nNOTE: quantmod::as.zoo.data.frame() is deprecated",
"\n Use as.zoo(x, order.by = as.Date(rownames(x))) instead.",
"\n This note is printed once. To see it for every call, set",
"\n options(quantmod.deprecate.as.zoo.data.frame = TRUE)\n")
}

# ignore row.date if order.by is specified
if(hasArg("order.by")) {
# Don't warn because behavior won't change when this method is removed
zoo(x,...)
}
#really need to test order - ???how?
else if(row.date) {
zoo(x,as.Date(rownames(x),origin='1970-01-01'),...)
}
else {
zoo(x,rownames(x),...)
} else {

warning("quantmod::as.zoo.data.frame() is deprecated and will be removed in a future version",
"\n Use zoo(x, order.by = as.Date(rownames(x))) instead.")

#really need to test order - ???how?
if(row.date) {
zoo(x,as.Date(rownames(x),origin='1970-01-01'),...)
}
else {
zoo(x,rownames(x),...)
}
}
}

Expand Down
9 changes: 0 additions & 9 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ print.quantmodEnv <- function(x, ...) {
#attach(NULL, name='.quantmodEnv')
}

# Loading quantmod produces the following message:
#
# Registered S3 method overwritten by 'quantmod':
# method from
# as.zoo.data.frame zoo
#
# Message users that this method will be deprecated in a future release.
options(quantmod.deprecate.as.zoo.data.frame = TRUE)

setOldClass("zoo");
setOldClass("xts");
setOldClass("Date");
Expand Down

0 comments on commit fb9c89c

Please sign in to comment.