[R-SIG-Finance] How to compute percentage change of xts ?
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Jul 2 22:06:50 CEST 2008
Assuming Open and Close are in columns 1 and 4:
100 * x[, 4] / x[, 1] - 100
logx <- log(x)
100 * (logx[, 4] - logx[, 1]) # common approximation
100 * diff(x[, c(1,4)], arith = FALSE) - 100
100 * diff(log(x[, c(1,4)])) # common approximation
On Wed, Jul 2, 2008 at 2:56 PM, <pierre8r-list at yahoo.fr> wrote:
> Helllo,
>
> Sorry, I repost my e-mail because I forgot the title.
>
> My script creates an xts object.
>
>
> First question:
> I would like to compute for each Open Close from this time-series, the percentage change.
> Is there a function that realizes this?
>
> Second question:
> I wish also to calculate the percentage change between two consecutive Close.
> Is there a function that realizes this?
>
> Thank you,
>
> Pierre8r
>
>
>
> ____________________________________________________________
> ente http://mail.yahoo.fr
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
More information about the R-SIG-Finance
mailing list