Skip to content
Prev 82679 / 398503 Next

Generation of missiing values in a time serie...

I think I have found the error. It appears when there are two entries  
with the same time. Using as input file:

--------- CUT --------
# Output format for PCKs:
# TIME FLOW P [+-] SEQ TS X RTT SIZE
#
123.125683 0 P + 967 123.125683 13394 0.798205 1472
123.241137 0 P + 968 123.241137 12680 0.796258 1472
123.241137 0 P + 969 123.241137 12680 0.796258 1472
123.472631 0 P + 970 123.472631 12680 0.796258 1472
123.588613 0 P + 971 123.588613 12680 0.796258 1472
123.704594 0 P + 972 123.704594 12680 0.796258 1472
--------- CUT --------

I run fhe following code:

--------- CUT --------
h_types <- list (0, 0, NULL, NULL, 0, 0, 0, 0, 0)
h_names <- list ("time", "flow",  "seq", "ts", "x", "rtt", "size")

pcks_file    <- pipe ("grep ' P ' data", "r")
pcks          <- scan (pcks_file, what = h_types, comment.char = '#',  
fill = TRUE)
mat_df      <- data.frame (pcks[1:2], pcks[5:9])
mat           <- as.matrix (mat_df)
colnames (mat)      <- h_names
z <- zoo (mat, mat [,"time"])
--------- CUT --------

The dput of 'z' shows:

--------- CUT --------
structure(c(123.125683, 123.241137, 123.241137, 123.472631, 123.588613,
123.704594, 0, 0, 0, 0, 0, 0, 967, 968, 969, 970, 971, 972, 123.125683,
123.241137, 123.241137, 123.472631, 123.588613, 123.704594, 13394,
12680, 12680, 12680, 12680, 12680, 0.798205, 0.796258, 0.796258,
0.796258, 0.796258, 0.796258, 1472, 1472, 1472, 1472, 1472, 1472
), .Dim = c(6, 7), .Dimnames = list(c("1", "2", "3", "4", "5",
"6"), c("time", "flow", "seq", "ts", "x", "rtt", "size")), index =  
structure(c(123.125683,
123.241137, 123.241137, 123.472631, 123.588613, 123.704594), .Names =  
c("1",
"2", "3", "4", "5", "6")), class = "zoo")
--------- CUT --------

If I try a 'as.ts(z)', it fails. If I remove the duplicate entry, I  
can convert it to a TS with no problem. Is this made intentionally?  
Because then I have to filter the input matrix... But, anyway, the  
output matrix, after filtering, doesn't seem regular:

--------- CUT --------
 > as.ts (z)
Time Series:
Start = 1
End = 5
Frequency = 1
       time flow seq       ts     x      rtt size
1 123.1257    0 967 123.1257 13394 0.798205 1472
2 123.2411    0 969 123.2411 12680 0.796258 1472
3 123.4726    0 970 123.4726 12680 0.796258 1472
4 123.5886    0 971 123.5886 12680 0.796258 1472
5 123.7046    0 972 123.7046 12680 0.796258 1472
Warning message:
?x? does not have an underlying regularity in: as.ts.zoo(z)
--------- CUT --------

Weird...
On 13 Dec 2005, at 16:33, Gabor Grothendieck wrote: