Hi, I am a R begginer and I have a small problem with time series. I was wondering if someone could help me I am collecting data from packets going through a network, and using R for obtaining some simple statistics of connections. However, my data is not collected at a constant frequency, so I would like to create a evenly spaced TS from my traces, using the minimum time difference between two samples as the period for my new TS, and filling the gaps with NA (or 0s). I think ther must be some simple solution for this... Anyone could help me? Thanks in advance. -- Alvaro Saurin <alvaro.saurin at gmail.com> <saurin at dcs.gla.ac.uk>
Gabor Grothendieck
2005-Dec-12 16:31 UTC
[R] Generation of missiing values in a time serie...
First we generate some sample data x and its times tt. Then using the zoo package we create an irregularly spaced time series. Now if you want a regularly spaced time series convert it to ts class. After loading zoo as shown below, the R command vignette("zoo") gives more info. x <- 1:4 tt <- c(1, 3, 4, 6) library(zoo) x.zoo <- zoo(x, tt) # irregularly spaced time series x.ts <- as.ts(x.zoo) # regular time series with NAs On 12/12/05, Alvaro Saurin <saurin at dcs.gla.ac.uk> wrote:> > Hi, > > I am a R begginer and I have a small problem with time series. I was > wondering if someone could help me > > I am collecting data from packets going through a network, and using > R for obtaining some simple statistics of connections. However, my > data is not collected at a constant frequency, so I would like to > create a evenly spaced TS from my traces, using the minimum time > difference between two samples as the period for my new TS, and > filling the gaps with NA (or 0s). > > I think ther must be some simple solution for this... Anyone could > help me? > > Thanks in advance. > > -- > Alvaro Saurin <alvaro.saurin at gmail.com> <saurin at dcs.gla.ac.uk> > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >