[R] Generate a time series from a data frame

Fredrick Paul Eisele phreed at netarx.com
Wed Nov 27 18:10:27 CET 2002

I imagine this is in the documentation somewhere but I haven't been able 
to find it.
I have a data frame (octets transmitted on a network interface, a sample 
is appended)
that I wish to convert into a time series.
The as.ts is close to what I want but not quite right.

 > octets <- read.table( "sample/time-series/typical-octets-in.data", 
header = TRUE );
 > octet.series <- as.ts( octets )
 > plot( octet.series )
This produces three plots: one each for the three variables, timestamp, 
maximum, average.
Of course, there is no regular interval.

I would to have a conversion fuction that aggregates the
data frames tuples into samples in the time series.
Something like...
 > octet.series <- x.ts( data = octets, times = 1, colums = c(2,3), 
deltat = 120, aggregate = c("max","mean" ) );

timestamp  maximum           average
1037669760 1.3262000000e+04  1.1481950000e+04
1037670000 1.9400200000e+04  1.4238516667e+04
1037670240 2.0456266667e+04  1.6628133333e+04
1037670480 2.1213200000e+04  1.9318616667e+04
1037670720 1.9905533333e+04  1.6954866667e+04
1037718480 1.8389866667e+04  1.7671633333e+04
1037718720 1.8000000000e+04  1.4151000000e+04

r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list