[R-SIG-Finance] Using abline with chartSeries

Joshua Ulrich josh.m.ulrich at gmail.com
Thu Apr 19 03:21:18 CEST 2012


On Mon, Apr 9, 2012 at 5:49 PM, Worik Stanton <worik.stanton at gmail.com> wrote:
> On 09/04/12 17:58, Joshua Ulrich wrote:
>>
>> Click the "Support Lists" tab on the right section of the page.  The
>> first three results answer your original question.
>
> That is, although helpful, a little obscure!
>
> Helpfully, to answer my own question:
>
>
>> > getSymbols("IBM")
>> [1] "IBM"
>> > IBM.m <- to.monthly(IBM)
>> > chartSeries(IBM.m, theme="white")
>> > abline(h=160)
>
> addLines(h=160, on=1)
>
> does the trick.
>
Nice find; even better than my suggestion.

> But how do I get a dotted line?
>
>> addLines(h=100, lty=2)
> Error in addLines(h = 100, lty = 2) : unused argument(s) (lty = 2)
>
> The "col" argument works to set a colour.
>
> Is there any documentation available?  Banging around google and mailing
> list archives is a very time consuming and frustrating process.
>
> ?addLines is not helpful.
>
It looks like you want something that hasn't been implemented, so you
have an opportunity to contribute to the community.  The simplest
answer is to patch addLines to pass the lty argument to chobTA at params
and chartLines.

But what about other potential arguments that could be passed to
abline (lwd, xpd, reg, coef)?  I'm sure you'd agree that a more
general solution would be nice, so maybe you could investigate how to
pass '...' (or the equivalent) to chartLines?

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

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



More information about the R-SIG-Finance mailing list