Re: [R] Averaging half hourly data to hourly

2010-06-28 Thread Joshua Ulrich
Hi Jenny,

 Date: Thu, 24 Jun 2010 09:45:10 +0100
 From: Jennifer Wright j.wright...@sms.ed.ac.uk
 To: r-help@r-project.org
 Subject: [R] Averaging half hourly data to hourly
 Message-ID: 4c231b16.1080...@sms.ed.ac.uk
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

 Hi all,

 I have some time-series data in half hourly time steps and I want to be
 able to either average or sum the two half hours together into hours.
 Any help greatly appreciated.

 Thanks,

 Jenny


 --
 The University of Edinburgh is a charitable body, registered in
 Scotland, with registration number SC005336.



See period.apply and endpoints in the xts package:

 require(xts)
 (x - .xts(1:10,(1:10)*1800))
[,1]
1969-12-31 18:30:001
1969-12-31 19:00:002
1969-12-31 19:30:003
1969-12-31 20:00:004
1969-12-31 20:30:005
1969-12-31 21:00:006
1969-12-31 21:30:007
1969-12-31 22:00:008
1969-12-31 22:30:009
1969-12-31 23:00:00   10
 period.apply(x, endpoints(x,hours), sum)
[,1]
1969-12-31 18:30:001
1969-12-31 19:30:005
1969-12-31 20:30:009
1969-12-31 21:30:00   13
1969-12-31 22:30:00   17
1969-12-31 23:00:00   10
 period.apply(x, endpoints(x,hours), mean)
[,1]
1969-12-31 18:30:00  1.0
1969-12-31 19:30:00  2.5
1969-12-31 20:30:00  4.5
1969-12-31 21:30:00  6.5
1969-12-31 22:30:00  8.5
1969-12-31 23:00:00 10.0


Best,
--
Joshua Ulrich
FOSS Trading: www.fosstrading.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Averaging half hourly data to hourly

2010-06-24 Thread Jennifer Wright

Hi all,

I have some time-series data in half hourly time steps and I want to be 
able to either average or sum the two half hours together into hours. 
Any help greatly appreciated.


Thanks,

Jenny


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Averaging half hourly data to hourly

2010-06-24 Thread Joris Meys
See ?aggregate

Cheers
J

On Thu, Jun 24, 2010 at 10:45 AM, Jennifer Wright
j.wright...@sms.ed.ac.uk wrote:
 Hi all,

 I have some time-series data in half hourly time steps and I want to be able
 to either average or sum the two half hours together into hours. Any help
 greatly appreciated.

 Thanks,

 Jenny


 --
 The University of Edinburgh is a charitable body, registered in
 Scotland, with registration number SC005336.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.