Having to collect hourly electricity loads and quarter-of-an-hour electricity production data for some years I think that the tidiest way of doing it is to resort to ts but I don't know how to define such a frequency starting from a set date. Leafing through r-help mail archives I've found this *ALMOST* satisfactory message: =========================================================......... > I have a series of hourly rainfall and quarterly flow> measurements (i.e. 4 times an hour) of a catchment........> Maybe time series are easier, but in > > ts(data = NA, start = X,... > > X should be a number or a vector. how does this coresponds to a > data and hour (e.g. april 26,2002, 15:00:00)?If your observations are equidistant, e.g. you've got 24 hourly measurements per day, you could do something like this for the above example: R> rain <- ts(rain, start = c(26, 15), freq = 24) R> flow <- ts(flow, start = c(26, 15), freq = 96) ........... =========================================================== But how does R know that we are speaking of a timeseries starting from April 26, 2002 and not, say, Feb 26, 2000? There's some piece of info missing in the answer. Am I correct? Please help. Ciao from Rome Vittorio
You may find the irregular time-series (its) package on CRAN helpful. If your raw data were in a csv file thus: x april 26 2002 15:00:00 1.1 april 26 2002 15:15:00 1.2 april 26 2002 15:30:00 1.3 april 26 2002 15:45:00 1.4 Then you could read it in thus: require("its") its.format("%B %d %Y %H:%M:%S") x <- its(readcsvIts("c:/temp/mydata.csv")) If on the other hand you already have the times in POSIX form, it is slightly simpler e.g. x <- its(xmat,POSIXdate) Giles> -----Original Message----- > From: v.demart at libero.it [mailto:v.demart at libero.it] > Sent: 22 October 2003 14:10 > To: r-help r-help > Subject: [R] High frequency time-series > > > Having to collect hourly electricity loads and > quarter-of-an-hour electricity production data for some years > I think that the tidiest way of doing it is to resort to ts > but I don't know how to define such a frequency starting from > a set date. > > Leafing through r-help mail archives I've found this *ALMOST* > satisfactory message: > =========================================================> ......... > > I have a series of hourly rainfall and quarterly flow > > measurements (i.e. 4 times an hour) of a catchment > ........ > > Maybe time series are easier, but in > > > > ts(data = NA, start = X,... > > > > X should be a number or a vector. how does this coresponds to a > > data and hour (e.g. april 26,2002, 15:00:00)? > > > If your observations are equidistant, e.g. you've got 24 hourly > measurements per day, you could do something like this for the above > example: > > > R> rain <- ts(rain, start = c(26, 15), freq = 24) > R> flow <- ts(flow, start = c(26, 15), freq = 96) > ........... > ===========================================================> > But how does R know that we are speaking of a timeseries > starting from April 26, 2002 and not, say, Feb 26, 2000? > There's some piece of info missing in the answer. > > Am I correct? > Please help. > > Ciao from Rome > > Vittorio > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >********************************************************************** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}
On Wednesday 22 October 2003 15:09, v.demart at libero.it wrote:> Having to collect hourly electricity loads and quarter-of-an-hour > electricity production data for some years I think that the tidiest > way of doing it is to resort to ts but I don't know how to define > such a frequency starting from a set date. > > Leafing through r-help mail archives I've found this *ALMOST* > satisfactory message: > =========================================================> ......... > > > I have a series of hourly rainfall and quarterly flow > > > > measurements (i.e. 4 times an hour) of a catchment > > ........ > > > Maybe time series are easier, but in > > > > ts(data = NA, start = X,... > > > > X should be a number or a vector. how does this coresponds to a > > data and hour (e.g. april 26,2002, 15:00:00)? > > If your observations are equidistant, e.g. you've got 24 hourly > measurements per day, you could do something like this for the above > example: > > > R> rain <- ts(rain, start = c(26, 15), freq = 24) > R> flow <- ts(flow, start = c(26, 15), freq = 96) > ........... > ===========================================================> > But how does R know that we are speaking of a timeseries starting > from April 26, 2002 and not, say, Feb 26, 2000? There's some piece > of info missing in the answer.Two possibilities: - ts(): you can just have a single number which counts the time unit. So you have to do that in a unique way. Either by convention or e.g. by augmenting the ts object by an additional attribute which gives the start date or something in that direction. - irts(): this is a function for definin irregularly spaced time series and it's available in the package "tseries". The time attribute is a vector of POSIXct times. This is more flexible in some sense, but requires the storage of more information. Furthermore, you have more functions around which can compute objects of interest based on "ts" object than on "irts" objects. hth, Z> Am I correct? > Please help. > > Ciao from Rome > > Vittorio > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help