[R] Add labels to my geom_hlines...

Levent TERLEMEZ lterlemez at anadolu.edu.tr
Mon Dec 29 18:04:55 CET 2014


Dear Users,

Would you pls help me to write a proper geom_text addition to geom_hline of my ggplot2.

This is d.oran

       Tarih  EUROUSD   USDJPY  EUROJPY
1 2005-01-01 1.378200 1.034654 1.425960
2 2005-01-02 1.373217 1.027268 1.410662
3 2005-01-03 1.364489 1.024884 1.398443
4 2005-01-04 1.352766 1.026722 1.388914
5 2005-01-05 1.338793 1.033870 1.384138

this is d.oran.ist

  x_bar    std_sap
EUROUSD 1.3405613 0.08739358
USDJPY  0.9909699 0.13757461
EUROJPY 1.3265161 0.18982005

and both of them are (in function) data frames. Here is my ggplot and i'd like to add texts to left edge of hlines like -3sigma, -2sigma,..., 3sigma.

Here is my ggplot line:

ggplot(data=d.oran)+geom_line(aes(x=Tarih,y=EUROUSD))+geom_hline(data=d.oran.ist,yintercept=x_bar[1]+c(-3:3)*std_sap[1],color=c("red","green","blue","black","blue","green","red"),linetype="dashed",lwd=1)


Thanks in advance.
Levent TERLEMEZ.

	[[alternative HTML version deleted]]



More information about the R-help mailing list