[R-SIG-Finance] Base R question on XTS object
Brian G. Peterson
brian at braverock.com
Wed Apr 10 12:17:51 CEST 2013
On 04/10/2013 04:45 AM, wlblount wrote:
> before the days of all these great packages, how would one with base R access
> only find the following assuming i have an XTS object with normal OHLC price
> data for 100 periods.
>
>
> 1 - change in price from yesterday to today. close[today] -
> close[yesterday]
?diff
(part of base)
> 2 -rolling or moving simple ave. of close[last 30 periods]
>
> 3 - rolling or moving sd of close[last 30 periods]
?apply
(in base)
?rollapply
(today)
Rollapply is basically a loop that constructs the windowed index.
> i understand that this would all be done with quantmod /ttr etc today but
> would just like to stay within the bounds of base R for educational
> purposes.
Then read an old book on S.
?ts
the 'ts' class has been part of the S language basically since inception.
Alternatively, all this code is open source. Look at the code.
Cheers,
Brian
More information about the R-SIG-Finance
mailing list