[R-SIG-Finance] addTA error message with text()

Jeff Ryan jeff.a.ryan at gmail.com
Mon Jan 18 01:47:27 CET 2010


There are two problems:

?addTA
Both 'addTA' and 'newTA' can be used to dynamically add custom
     content to a displayed chart.

     'addTA' takes a series of values, either in a form coercible to
     'xts' or of the same length as the charted series has rows, and
     displays the results in either a new TA sub-window, or

So text() isn't "a series of values".  Clearly not the same length, or
anything remotely like the requirements.

The second is the chart from chartSeries doesn't use "index" for an
x-axis, it is closer to:

x.pos <- 1 + x at spacing * (1:x at length - 1)

Though as the docs mention chartSeries isn't really compatible with
base graphics anyway.

So what you want is _possible_, but is probably not going to be what
you really want:

Try:

> chartSeries(BARC,TA=NULL)
> text(1:NROW(BARC), Cl(BARC), labels=Cl(BARC), col='white')

You'll see that it is a visual disaster.  If you tell us what you want
to accomplish, it may be easier to redirect you.

One final comment, chartSeries in quantmod is about 2 weeks away from
the introduction of an updated set of charting tools.  These will
allow for much more mixing with traditional graphics in R.  I'll keep
the list posted when this is available.

Best,
Jeff




On Sun, Jan 17, 2010 at 5:55 PM, andrew morgan <minkymorgan at gmail.com> wrote:
> Hi list,
>
> I'm trying to use text() with addTA + chartSeries to label points.
> In testing this idea out, I'm getting an error message I don't know
> how to interpret.
> Can anyone explain what it means, or what I'm doing wrong here?
>
> Contrived example, and error message below.
>
> BARC <- get.hist.quote(instrument = "BARC.L", start = "2000-01-01",
> end = "2010-04-04")
> chartSeries(BARC)
> addTA(text(index(BARC), BARC$Close, as.character(BARC$Close)))
>
> # error is:
> Error in addTA(text(index(BARC), BARC$Close, as.character(BARC$Close))) :
>  non-xtsible data must match the length of the underlying series
>
> In what way is the data not the same length?
> Is there a simple way to label points?
>
> many thanks
>
> Andrew
>
> _______________________________________________
> 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.
> -- Also note that this is not the r-help list where general R questions should go.
>



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list