R percent from start

Discussion in 'Programming' started by Craig66, Jun 20, 2012.

  1. Craig66

    Craig66

    If I have a zoo based time-series in R, is there a simple one-liner way of turning it into a percentage from the first observation?

    e.g.

    1,2,3,6 -> 0,100,50,100
     
  2. Hi Craig,
    From your example, I think you are asking for relative adjacent returns?

    try :
    library(quantmod)
    x<-c(1,2,3,6)

    100*Delt(x)

    returns:
    Delt.1.arithmetic
    [1,] NA
    [2,] 100
    [3,] 50
    [4,] 100
     
  3. Craig66

    Craig66

    Yep, cheers dude.
    I actually had read about Delt but my brain is obviously have trouble getting started today...