[BioC] xtable links

Gregoire Pau gregoire.pau at ebi.ac.uk
Sat Dec 6 17:34:32 CET 2008


Hi Tim,

Alternatively, you may want to use the CRAN package hwriter:

library(hwriter)
mat=matrix(1:24,6,4)
colnames(mat)=1:4
hmat=hwrite(mat, col.link=list('4'=rep('http://nytimes.com', 6)), 
col.names=T, row.style='text-align:center ; font-weight:bold')
hcap=hwrite('test', center=T)
hwrite(c(hmat,hcap), 'test.html', dim=c(2,1), border=0)

For more details and CSS styling options, please check:
http://www.ebi.ac.uk/~gpau/hwriter/

Best regards,

Greg
-- 
Gregoire Pau
EMBL/EBI Cambridge, UK
http://www.ebi.ac.uk/~gpau

Tim Smith wrote:
> Thanks Sean.
> 
> The table itself seems to come out fine in the browser - only the hyperlinks don't work! Everything else appears to be formatted.
> 
> 
> 
> 
> 
> 
> 
> ________________________________
> From: Sean Davis <sdavis2 at mail.nih.gov>
> 
> Cc: bioc <bioconductor at stat.math.ethz.ch>
> Sent: Friday, December 5, 2008 4:17:46 PM
> Subject: Re: [BioC] xtable links
> 
> 
>> Hi,
>>
>> I was trying to get hyperlinks using xtable, but couldn't get the hyperlinks to function properly. For example, if I use
>>
>> ## Try to link NY times website to every figure in column 4
>> mat <- matrix(1:43,6,5)
>> mat[,5] <- "http://nytimes.com"
>>
>> for(i in 1:nrow(mat)){
>>    strr <-  paste('<a href="', mat[i,5],'">', mat[i,4], '</a>', sep='')
>>    mat[i,4] <- strr
>> }
>> mat2 <- mat[,1:4]
>>
>> caption = 'test'
>> mx <- xtable(mat2,caption=caption)
>> tt = print(mx, type="html",include.rownames=F)
>> tt1 <- gsub('lt /a','lt/a',tt,fixed=T)
>> tt2 <- gsub('lt a','lta',tt1,fixed=T)
>>
>> write.table(tt2,'test.html',quote=F)
> 
> xtable converts the table to HTML.  You won't want to use write.table
> on that.  Use something like writeLines().  Also, the HTML output by
> xtable is only the "table" part; you will need to put appropriate HTML
> header, body, etc. around the table in order for it to work in a
> browser.
> 
>> However, if I open 'test.html' in IE, the hyperlinks don't seem to work. What am I doing wrong?
>>
>> thanks.
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
> 
> 
> 
>       
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list