The following seems confused (0.65 snapshot)> x <- ts(1:20) > window(x, 1, 1)Time Series: Start = c(1, 1) End = c(1, 1) Frequency = 1 [1] 1 Warning message: Not returning a time series object in: [.ts(x, i) (it of class ts, as the print method shows). Under 0.64.2 it is even more confusing:> x <- ts(1:20) > window(x, 1, 1)Warning: Not returning a time series object Time Series: Start = c(1, 1) End = c(1, 1) Frequency = 1 [1] 1 sic!> x[1][1] 1 Warning message: Not returning a time series object in: [.ts(x, 1) Is there any good reason why a time series of length one is not allowed by [.ts (you can certainly create one with ts)? How about one of length 0:> ts(numeric(0))Time Series: Start = c(1, 1) End = c(0, 1) Frequency = 1 numeric(0) (which is surely a bug in print.ts if length 0 objects are allowed).> x[0]numeric(0) Warning message: Not returning a time series object in: [.ts(x, 0) I suggest we should allow time series of length 1 but not of length 0 (as they have no start). -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 10-Aug-99 ripley@stats.ox.ac.uk wrote:> Is there any good reason why a time series of length one is not > allowed by [.ts (you can certainly create one with ts)?It certainly has a start and an end value, but what's the frequency? If you want the tsp attribute of a time series to be well defined, then maybe you should disallow series of length 1. "[.ts" certainly needs fixing. There has been some discussion about this and I think the consensus was that "[.ts" should not attempt to return a time series when taking row subsets (computationally expensive, and quite difficult to cover all cases, see PR#216, PR#217). The window() function is more appropriate for taking subseries IMHO. Martyn -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Wed, 11 Aug 1999 13:52:51 +0200 (CEST) > From: Martyn Plummer <plummer@iarc.fr> > To: Prof Brian D Ripley <ripley@stats.ox.ac.uk> > Subject: RE: Is a ts of length one a ts? (PR#245) > Cc: r-devel@stat.math.ethz.ch, R-bugs@biostat.ku.dk > > On 11-Aug-99 Prof Brian D Ripley wrote: > > On Wed, 11 Aug 1999, Martyn Plummer wrote: > > > >> On 10-Aug-99 ripley@stats.ox.ac.uk wrote: > >> > Is there any good reason why a time series of length one is not > >> > allowed by [.ts (you can certainly create one with ts)? > >> > >> It certainly has a start and an end value, but what's the > >> frequency? If you want the tsp attribute of a time series > >> to be well defined, then maybe you should disallow series > >> of length 1. > > > > I think the frequency is perfectly well defined, as that of the series you > > subsetted. > > Is it? > > R 0.64.2: > > R> x <- ts(1:10) > R> frequency(x) > [1] 1 > R> y <- x[c(2,4,6,8,10)] > R> frequency(y) > [1] 0.5 >I was only discussing the case of a subset of one, but you omitted the next sentence. What I actually said was `I think the frequency is perfectly well defined, as that of the series you subsetted. How can extracting one observation change the frequency of observation?' Obviously, subsetting a regularly spaced series can change the frequency. -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._