I save a plot generated with R with the pdf()
function (see below). Is it possible, to add clickable hyperlinks to this plot? Alternatives to pdf()
are welcome.
pdf(file="plot.pdf",width=20,height=50)
q <- ggplot(df, aes(x=reorder(desc,Value, FUN=median), y=Value))
q + geom_boxplot(aes(fill = factor(role)))+ coord_flip()
dev.off()
where the df$desc
looks like this:
[1] "http://www.jcvi.org/cgi-bin/tigrfams/HmmReportPage.cgi?acc=TIGR02914 # EpsI_fam: EpsI family protein # Role: 141"
[2] "http://www.jcvi.org/cgi-bin/tigrfams/HmmReportPage.cgi?acc=TIGR03067 # Planc_TIGR03067: Planctomycetes uncharacterized domain TIGR03067 # Role: 157"
[3] "http://www.jcvi.org/cgi-bin/tigrfams/HmmReportPage.cgi?acc=TIGR03021 # pilP_fam: type IV pilus biogenesis protein PilP # Role: 91"
In the pdf, the link is not clickable.
Here's how to add hyperlinks to any PDF: Open your PDF in Adobe Acrobat. Select Edit PDF from the toolbar. Choose Link > Add or Edit.
You could do this with Rsweave. Rsweave lets you call R from within LaTeX.
So an example file using my own made up data would be:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<echo=FALSE,fig=TRUE>>=
library(ggplot2)
q <- ggplot() + geom_point(data=data.frame(x = c(1,2,3,4),y=c(4,3,2,1)), aes(x=x,y=y))
print(q)
@
\par{
\url{http://google.com}
}
\end{document}
And you can compile this from Rstudio. It will know what to do if the file has an .rnw extension. If you are compiling from R then you can use the Sweave command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With