From ggrothendieck at myway.com  Sat Mar 26 17:28:19 2005
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Sat Mar 26 17:30:16 2005
Subject: [Rd] na.omit error message
References: <loom.20050326T034901-417@post.gmane.org>
Message-ID: <loom.20050326T172614-258@post.gmane.org>

Gabor Grothendieck <ggrothendieck <at> myway.com> writes:

: 
: If I create a bivariate ts series with 3 time points and run
: na.omit on it expecting it to reduce it to a one point ts series
: instead I get the following error messasge:
: 
: R> hh <- ts(matrix(c(NA,1:4,NA),3), start = c(1951,8), freq=12)
: R> hh
:          Series 1 Series 2
: Aug 1951       NA        3
: Sep 1951        1        4
: Oct 1951        2       NA
: R> na.omit(hh)
: Error in "tsp<-"(`*tmp*`, value = c(1951.66666666667, 1951.66666666667,  : 
:         invalid time series parameters specified
: 
: If I replace na.omit with na.contiguous then I get a protection stack
: overflow:
: 
: R> na.contiguous(hh)
: Error: protect(): protection stack overflow
: 
: R> R.version.string # Windows XP
: [1] "R version 2.1.0, 2005-03-23"
: 
: Any comments on what is wrong?
: 



I am not sure if this is related to the last
problem or not but its a problem at any rate.
This is from R 2.1.0 March 23, 2005 on Windows XP.

1. stats:::.cbind.ts
====================

In stats:::.cbind.ts the line which is commented below
(which is currently in the existing R code) should 
be replaced by the line following it which I have 
added to take into account floating point 
approximations:

    if (union) {
        st <- min(tsps[1, ])
        en <- max(tsps[2, ])
    }
    else {
        st <- max(tsps[1, ])
        en <- min(tsps[2, ])
        # if (st > en) {
	if (st > en + getOption("ts.eps")) {  # replaces commented line
            warning("non-intersecting series")
            return(NULL)
        }
    }

2. stats:::window.default
=================

Also, for the same reason, in stats:::window.default, the 
line which I have commented should be changed to the
following line that is not commented:

    # if (start > end) 
    if (start > end + ts.eps)  # replaces commented line
        stop("'start' cannot be after 'end'")

also to take into account floating point approximations.


[Rd] na.omit error message
Gabor Grothendieck