[R] Percent Change After Each Interval

From: Jia Ying Mei <jiamei_at_princeton.edu>
Date: Wed, 30 Jul 2008 11:18:45 -0400


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



R-help_at_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. Received on Wed 30 Jul 2008 - 15:21:40 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 Wed 30 Jul 2008 - 15:32:58 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.

list of date sections of archive