jcano
2009-Oct-20 14:30 UTC
[R] How to create a legend that automatically reads the values from two vectors?
Hi all!!! How can I create a legend to my plot that automatically reads the values from two vectors? betav<-c(0.78,0.94,0.88,0.41,0.59,4.68) etav<-c(235.6,59.5,31.2,8.7,3.2,1174) I want my legend to show 6 lines beta(in greeks)=0.78,eta(in greeks)=235.6 beta(in greeks)=0.94,eta(in greeks)=6.59 .... beta(in greeks)=4.68,eta(in greeks)=1174 I know how to do it "by hand" but I have to write them one by one and this is not efficient. How can I do that? I guess it has to be with the lapply or rapply functions, but I can't really get it!!!! Many thanks in advance Best regards Javier -- View this message in context: http://www.nabble.com/How-to-create-a-legend-that-automatically-reads-the-values-from-two-vectors--tp25976164p25976164.html Sent from the R help mailing list archive at Nabble.com.
Jim Lemon
2009-Oct-21 08:56 UTC
[R] How to create a legend that automatically reads the values from two vectors?
On 10/21/2009 01:30 AM, jcano wrote:> betav<-c(0.78,0.94,0.88,0.41,0.59,4.68) > etav<-c(235.6,59.5,31.2,8.7,3.2,1174) >Hi Javier, Maybe not exactly what you want, but try: addtable2plot(2,8,rbind(betav,etav),bty="o", display.colnames=FALSE,display.rownames=TRUE) using your own x and y coordinates, of course. addtable2plot is in the plotrix package. Jim