From KjetilBrinchmannHalvorsen at gmail.com  Wed Feb  1 02:07:28 2006
From: KjetilBrinchmannHalvorsen at gmail.com (KjetilBrinchmannHalvorsen@gmail.com)
Date: Wed,  1 Feb 2006 02:07:28 +0100 (CET)
Subject: [Rd] window()   problem (PR#8545)
Message-ID: <20060201010728.C3C4A3D5BB@slim.kubism.ku.dk>

window() does not work correctly when called with extend=TRUE  and
the new time range intersect null with the old time range! Maybe this is 
really a feature request, but the documentation does not say what to 
expect in this case.

This case does occur in programming!

This is R2.2.1 on windows, latest compiled from CRAN.

Look at the excerps below:

 > test <- ts(1:144, start=c(1,1), frequency=12)
 > tsp(test)
[1]  1.00000 12.91667 12.00000
 > test2 <- window(test, start=c(5,1), end=c(16,4), extend=TRUE)
 > test2
    Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
5   49  50  51  52  53  54  55  56  57  58  59  60
6   61  62  63  64  65  66  67  68  69  70  71  72
7   73  74  75  76  77  78  79  80  81  82  83  84
8   85  86  87  88  89  90  91  92  93  94  95  96
9   97  98  99 100 101 102 103 104 105 106 107 108
10 109 110 111 112 113 114 115 116 117 118 119 120
11 121 122 123 124 125 126 127 128 129 130 131 132
12 133 134 135 136 137 138 139 140 141 142 143 144
13  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
14  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
15  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
16  NA  NA  NA  NA
 > tsp(test2)
[1]  5.00 16.25 12.00
 > test3 <- window(test, start=c(15,1), end=c(17,1), extend=TRUE)
Error in window.default(x, ...) : invalid time series parameters specified

Enter a frame number, or 0 to exit

1: window(test, start = c(15, 1), end = c(17, 1), extend = TRUE)
2: window.ts(test, start = c(15, 1), end = c(17, 1), extend = TRUE)
3: as.ts(window.default(x, ...))
4: window.default(x, ...)

Selection: 4
Called from: eval(expr, envir, enclos)
Browse[1]> x
    Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1    1   2   3   4   5   6   7   8   9  10  11  12
2   13  14  15  16  17  18  19  20  21  22  23  24
3   25  26  27  28  29  30  31  32  33  34  35  36
4   37  38  39  40  41  42  43  44  45  46  47  48
5   49  50  51  52  53  54  55  56  57  58  59  60
6   61  62  63  64  65  66  67  68  69  70  71  72
7   73  74  75  76  77  78  79  80  81  82  83  84
8   85  86  87  88  89  90  91  92  93  94  95  96
9   97  98  99 100 101 102 103 104 105 106 107 108
10 109 110 111 112 113 114 115 116 117 118 119 120
11 121 122 123 124 125 126 127 128 129 130 131 132
12 133 134 135 136 137 138 139 140 141 142 143 144
Browse[1]> tsp(x)
[1]  1.00000 12.91667 12.00000
Browse[1]> y
  [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 
NA NA NA NA NA NA NA NA NA
[32] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
Browse[1]> tsp(y)
NULL
Browse[1]>

As one can see from the above, the calculated answer y does not have a
tsp attribute.

Kjetil



[Rd] window() problem (PR#8545)
KjetilBrinchmannHalvorsen@gmail.com