[R] Yearly statistics

From: Alfonso Sammassimo <cincinattikid_at_bigpond.com>
Date: Mon, 28 May 2007 13:22:05 +1000


Dear R-experts,

Sorry if I've overlooked a simple solution here. I have calculated a proportion of the number of observations which meet a criteria, applied to five years of data. How can I break down this proportion statistic for each year?

For example (data in zoo format):

                    open  high   low    close  hc  lc
2004-12-29 4135 4135 4106  4116  8 -21
2004-12-30 4120 4131 4115  4119 15  -1
2004-12-31 4123 4124 4114  4117  5  -5
2005-01-04 4106 4137 4103  4137 20 -14
2005-01-06 4085 4110 4085  4096 10 -15
2005-01-10 4133 4148 4122  4139 15 -11

2005-01-11 4142 4158 4127 4130 19 -12
2005-01-12 4113 4138 4112 4127 18 8

Statistic of interest is proportion of times that sign of "hc" is positive and sign of "lc" is negative on any given day. Looking to return something like:

Yr Prop
2004 1.0
2005 0.8

Along these lines, if I have datasets A and B, where B is a subset of A, can I use the number of matching dates to calculate the yearly proportions in question?

Thanks,
Alfonso Sammassimo
Melbourne Australia



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 and provide commented, minimal, self-contained, reproducible code. Received on Mon 28 May 2007 - 09:25:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 May 2007 - 13:31:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.