[R] Percent Change After Each Interval

Jia Ying Mei jiamei at Princeton.EDU
Wed Jul 30 17:18:45 CEST 2008


Hi,

I have a data set (attached, and which I've asked about before) 
containing countries, prices and dates. I am trying to find the mean and 
median (by country) percentage change of each price change. For example:

Date                  Australia
6/30/07                         2
3/31/07                         2
11/30/06                       2
5/2/06                           2
1/11/06                         2
8/5/05                           2
7/31/05                         2
4/30/05                       1.5
1/31/05                       1.5
1/3/05                         1.5
1/2/05                            4

So for this period for Australia, there are 2 price changes. The first 
change is a 25% change, and the second is 266.66%. If this were all the 
data there was, the mean percentage change is ~146% and the median would 
be the same.

I was wondering if anyone knew a way that would collect the percentage 
change at each price change and then calculate the mean and median of 
those percentages, and could do this for a data set with a lot of 
countries (so the output would be broken up by country).

Any help would be appreciated! Thanks!

Jia Ying Mei


More information about the R-help mailing list