[R] Can a hyperlink be placed, thorugh R programming, on a graph?
jim at bitwrit.com.au
Fri Apr 27 12:23:36 CEST 2007
Aldi Kraja wrote:
> If I use
> ### pdf(file="c:\\aldi\\test.pdf")
> ### dev.off()
> ### q()
> Is there a way that I can imbed in the graph plot for each point defined
> by x to x+0.5 and y to y+0.5 (and colored in green) a different hyperlink?
> For example point one (together with the green tail) will have the
> hyperlink: www.r-project.org; point 2 with the link www.google.com;
> point 3 with the link www.yahoo.com etc.
> So in general, can the graph be manupulated within R?
In HTML, the way to do this is usually known as an image map. Here is
one way to accomplish this.
After generating the image in a format that will display on an HTML
page, create the page.
<title>HTML image map demo</title>
<center>Click on one of the points to go to another URL</center><p>
<img src="aldi.png" width="480" height="480" usemap="#aldiplot"
<map id="aldiplot" name="aldiplot">
<area shape="circle" coords="79,286,10" alt="P1"
<area shape="circle" coords="119,77,10" alt="P2"
<area shape="circle" coords="158,124,10" alt="P2"
Now if you point your browser at that HTML page, you should be able to
click on the first three points and be transferred to the URLs in your
example. Doing this in PDF should be pretty similar, but I don't know
how to write PDF code.
However, if you look at the code in either the R2HTML package or the
prettyR package, you can see how this could all be generated in R.
More information about the R-help