From ripley at stats.ox.ac.uk  Tue Aug  3 18:53:28 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue Aug  3 18:53:38 2004
Subject: [Rd] (PR#7152) Ops.ts returns non-ts object for univariate
	operations
In-Reply-To: <20040803160737.12726112F8@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.44.0408031743550.24106-100000@gannet.stats>

How about a statement of the problem and an example?  It is not clear to
me that there is anything here that is not intentional, and the stated
analysis is plain wrong: Ops.ts _is_ called for univariate "-" and _does_
return a time series.

Both +a.ts and -a.ts return a ts.  !a.ts does not, but we expect time 
series to be numeric so that is deliberate.  (Copying attributes wily-nily 
when changing mode is not a good idea.)

On Tue, 3 Aug 2004 jpalmucci@machineinsight.com wrote:

> Full_Name: Jeff Palmucci
> Version: 1.9.1
> OS: XP
> Submission from: (NULL) (129.44.190.60)
> 
> 
> Ops.ts returns a non-time series object for univariate operations. Here is a
> patch:
> 
> Ops.ts <- function(e1, e2)
> {
>     if(missing(e2)) {
>         ## univariate operator
>       result <- NextMethod(.Generic)
>       attributes(result) <- attributes(e1)
>       result
>     } else if(any(nchar(.Method) == 0)) {
>         ## one operand is not a ts
>         NextMethod(.Generic)
>     } else {
>         nc1 <- NCOL(e1)
>         nc2 <- NCOL(e2)
>         ## use ts.intersect to align e1 and e2
>         e12 <- .cbind.ts(list(e1, e2),
>                          c(deparse(substitute(e1))[1],
>                            deparse(substitute(e2))[1]),
>                          union = FALSE)
>         e1 <- if(is.matrix(e1)) e12[, 1:nc1, drop = FALSE] else e12[, 1]
>         e2 <- if(is.matrix(e2)) e12[, nc1 + (1:nc2), drop = FALSE]
>         else e12[, nc1 + 1]
>         NextMethod(.Generic)
>     }
> }
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] (PR#7152) Ops.ts returns non-ts object for univariate operations
Prof Brian Ripley