Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

My Data has the following form:

 Individual Year    X2009Int    X2008Int    X2007Int
      1     2011    10.36703    18.07049    4789.338
      2     2011    10.36703    18.07049    4789.338
      3     2010    10.36703    18.07049    4789.338
      4     2010    10.36703    18.07049    4789.338
      5     2009    10.36703    18.07049    4789.338
      6     2009    10.36703    18.07049    4789.338

Where the X2009Int, X2008Int, X2007Int columns represent the severity of a particular event at those specified time periods. My aim is to create a function which I can loop across columns to create the following:

 Individual Year      T           T-1          T-2         T-3
      1     2011      0            0         10.36703    18.07049
      2     2011      0            0         10.36703    18.07049
      3     2010      0         10.36703     18.07049    4789.338
      4     2010      0         10.36703     18.07049    4789.338
      5     2009    10.36703    18.07049     4789.338       0
      6     2009    10.36703    18.07049     4789.338       0

To further illustrate what's going on take Individual 5 in Year 2009. Under the $T column I would need the event intensity value in X2009Int , $T-1 column = value from X2008Int, $T-2 = X2007Int, $T-3 = X2006Int, etc. (Years range from 2012-1980)

Any help is much appreciated!

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.