Skip to content

Commit 96b4798

Browse files
committed
Do not warn when .xts ctor ignores tclass
The current behavior ignores the tclass attribute on the index passed to .xts(). This is a bug, but throwing a warning breaks existing packages and causes errors in their CRAN checks. Reinstate the warning after fixing dependencies. See #245.
1 parent 45ff1ad commit 96b4798

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

R/xts.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ function(x=NULL, index, tclass=c("POSIXct","POSIXt"),
166166
# tclass argument will override the index attribute, but it shouldn't...
167167
index.class <- attr(index, 'tclass')
168168
default.class <- c("POSIXct", "POSIXt")
169-
if(!is.null(index.class) && !all(index.class %in% default.class)) {
170-
warning("the index tclass attribute is ", index.class,
171-
" but will be changed to (POSIXct, POSIXt)")
172-
}
169+
### FIXME:
170+
### This warning causes errors in dependencies (e.g. portfolioBacktest,
171+
### when the warning is thrown from PerformanceAnalytics). Reinstate this
172+
### warning after fixing downstream packages.
173+
### if(!is.null(index.class) && !all(index.class %in% default.class)) {
174+
### warning("the index tclass attribute is ", index.class,
175+
### " but will be changed to (POSIXct, POSIXt)")
176+
### }
173177
}
174178

175179
if(hasArg(".indexTZ")) {

inst/unitTests/runit.xts.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ test..xts_dimnames_in_dots <- function() {
114114
}
115115

116116
test..xts_ctor_warns_if_index_tclass_not_NULL_or_POSIXct <- function() {
117+
DEACTIVATED("Warning causes errors in dependencies")
117118
op <- options(warn = 2)
118119
on.exit(options(warn = op$warn))
119120

0 commit comments

Comments
 (0)