I have a large matrix consisting of 116 columns and 4700 rows.
For each row I would like to compute a standardized difference of the following form:
(((a2-a1)/a1)*100)+100, where a1 is the previous value and a2 is the next value.
In R I'm using the following code:
for i in (1:116)
a[i]=(((a[i]-a[i-1])/a[i-1])*100)+100
However I get the following error:
Error in Ops.data.frame(a[i], a[i - 1]) :
- only defined for equally-sized data frames
I'm guessing that the problem is that it does not take into account the very first value, where there does not exist a first value-1 to substract.
How can I solve this problem?
Here's a subset of the data: https://dl.dropbox.com/u/22681355/su.csv
Remember that I would like to calculate for each column individually!