Quantcast

Numeric to timeSeries help

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Numeric to timeSeries help

Golam Sakline
Hi,

Can someone quickly help me with few lines of code or point me to a site that shows how to merge a numeric class object column with time column of getSymbol object and plot it in quantmod chartSeries.
Much appreciated.

Thanks in advance

Riskmaverick

Sent from my iPhone
_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Numeric to timeSeries help

braverock
On Mon, 2012-03-26 at 13:59 +0100, Golam Sakline wrote:
> Hi,
>
> Can someone quickly help me with few lines of code or point me to a site that shows how to merge a numeric class object column with time column of getSymbol object and plot it in quantmod chartSeries.
> Much appreciated.

A little more specificity might have helped...

getSymbols("IBM")
IBM$Random<-rnorm(nrow(IBM))
chart_Series(IBM)
add_Vo()
add_TA(IBM$Random)

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Numeric to timeSeries help

Joshua Ulrich
In reply to this post by Golam Sakline
On Mon, Mar 26, 2012 at 7:59 AM, Golam Sakline <[hidden email]> wrote:
> Hi,
>
> Can someone quickly help me with few lines of code or point me to a site that shows how to merge a numeric class object column with time column of getSymbol object and plot it in quantmod chartSeries.

There's no such thing as a "getSymbol" object.  By default getSymbols
returns an xts object.  xts objects do not have a "time column"; they
have an index attribute that stores the date/time.

What did you try?  This works:
x <- xts(1:10, Sys.Date()+1:10)
x <- merge(x,10:1)

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

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

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Numeric to timeSeries help

Jeffrey Ryan
In reply to this post by Golam Sakline
?merge.xts is what you need.

It will behave like you'd expect in R - requiring a vector of length ==
nrow of your object, or will be recycled as needed. e.g. cbind(x, NA) will
recycle NA accordingly

HTH
Jeff

On 3/26/12 7:59 AM, "Golam Sakline" <[hidden email]> wrote:

>Hi,
>
>Can someone quickly help me with few lines of code or point me to a site
>that shows how to merge a numeric class object column with time column of
>getSymbol object and plot it in quantmod chartSeries.
>Much appreciated.
>
>Thanks in advance
>
>Riskmaverick
>
>Sent from my iPhone
>_______________________________________________
>[hidden email] 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.

_______________________________________________
[hidden email] 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.
Loading...