[R-SIG-Finance] [R-sig-finance] xts feature

Murali.MENON at fortisinvestments.com Murali.MENON at fortisinvestments.com
Mon Jan 26 19:15:09 CET 2009


 
Hi Jeff,

With that same dataset of Kafkaz's, if we wanted to compute the mean of
all the 15:30:00 Volume datapoints (there are two here), how would we do
it? The code you give below will perform the 'mean' operation on all
data points falling within each hour, but separate them day-by-day, if
that makes sense.

Would I have to do something like 

mean(x[grep("15:30:00", index(x)), "Volume"])

This works with a POSIXct index, but seems to assume that there is a
character representation for the time index?

Cheers,
Murali


-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Jeff Ryan
Sent: 26 January 2009 17:31
To: kafkaz
Cc: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] [R-sig-finance] xts feature

Hi Kafkaz,

Try something like:

period.apply(Vo(x), endpoints(x, 'hours'), mean)

Useful tools from xts that are of interest:

?period.apply, ?endpoints, ?to.period

You can also use aggregate, which on xts objects will call the method
from the zoo package (automatically loaded).

HTH
Jeff

R/Finance 2009: Applied Finance with R
April 24, 25th Chicago, IL

http://www.quantmod.com/news/  http://www.RinFinance.com

--
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com

_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.



More information about the R-SIG-Finance mailing list