r - How can I include hyperlinks in a table within an Sweave document? -


i have data frame containing hyperlinks present clickable links using sweave. know xtable, not sure how use treat contents of data frame latex commands.

one strategy use sanitize.text.function print function in xtable. setting sanitize.text.function = function(x){x} causes print echo contents of data frame later interpretation latex:

\documentclass{article}  \usepackage{hyperref}  \begin{document} \title{example of how include hyperlinks in sweave \texttt{xtable}} \author{david r. lovell} \maketitle  <<load-packages, include=false>>= require(xtable) @  <<read-data, tidy=false>>= hits <- read.table(textconnection( "count,link,title 1031,http://australianbioinformatics.net/jobs,jobs 796,http://australianbioinformatics.net/,home"), stringsasfactors=false, sep=",", header=true) @  <<print-xtable, echo = false, results = 'asis'>>= print(   xtable(     hits,     align="rrll",     caption="top content on \\href{http://australianbioinformatics.net}{australianbioinformatics.net} in may 2014."     ),    include.rownames=false   ) @  <<print-xtable-href, echo = false, results = 'asis'>>= linkedhits <- transform(hits, href=paste("\\href{", link, "}{", title, "}", sep="")) print(   xtable(     subset(linkedhits, select=c(count, href)),     align="rrl",     caption="top content on \\href{http://australianbioinformatics.net}{australianbioinformatics.net} in may 2014,      added hyperlinks."     ),    include.rownames=false,   sanitize.text.function = function(x){x}   )  @  \end{document} 

...which produces pdf output: enter image description here


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -