[R-SIG-Finance] xts to timeSeries conversion

Jeffrey Ryan jeffrey.ryan at lemnica.com
Sat Mar 24 15:08:21 CET 2012


as.XXXXXX is the R way to coerce objects, and xts follows this (as do
most of the time series classes)

One of the original design goals of xts was to remove the issues
surrounding all of the different time series classes that may be in R.
 R developers can convert to xts internally via try.xts and return
original object classes with "reclass".  PeformanceAnalytics does this
quite well, which makes it easy for users to pass in any time series
object - regardless of class.

At the user level, as.xts or as.XXXXX is all that is needed if you are
forced to convert, but as Brian points out - this isn't needed in PA
or other packages that use the xts methodology for internally
consistent conversions.

In short, it should (does) just work.  If it isn't, your data is
likely different than what you are telling us, but we'd need example
code as requested in the posting guides to be more helpful.

Best,
Jeff

On Sat, Mar 24, 2012 at 8:58 AM, Golam Sakline <golam.sakline at gmail.com> wrote:
> Hi Michael,
>
> Thank you for you reply, but in general are you aware of any ways to convert xts date to timeSeries date using intermediate data.frame conversion in between.
>
> Thank you in advance.
>
> Golam
>
> Sent from my iPhone
>
> On 24 Mar 2012, at 13:13, "R. Michael Weylandt" <michael.weylandt at gmail.com> wrote:
>
>> I'm not sure I understand. PerformanceAnalytics is part of the
>> "xts-family" (as opposed to the Rmetrics family) of finance packages.
>> Your problem may be that it requires returns, but consider this
>> (somewhat opaque) one liner.
>>
>> charts.PerformanceSummary(ROC(Cl(to.weekly(Ad(getSymbols("IBM",auto.assign
>> = F))))))
>>
>> which works just fine (using 3 packages explicitly and two major dependencies!)
>>
>> Michael
>>
>> On Sat, Mar 24, 2012 at 9:01 AM, Golam Sakline <golam.sakline at gmail.com> wrote:
>>> How is it possible to get getSymbol object like IBM stock converted to timeSeries object so that it can be plotted in charts.PerformanceSummary() of PerformanceAnalytics in few lines of code. The problem I am having is with the Date column. Please help.
>>>
>>> Thanks
>>>
>>> Riskmaverick
>>>
>>> Sent from my iPhone
>>> _______________________________________________
>>> R-SIG-Finance at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>> -- Also note that this is not the r-help list where general R questions should go.
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com
www.esotericR.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com

See you in Chicago!!!!



More information about the R-SIG-Finance mailing list