使用超链接将R中的表导出为HTML [英] exporting table in R to HTML with hyperlinks
本文介绍了使用超链接将R中的表导出为HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
虽然这个问题更一般地在这里看过:
我特别想知道如何使数据框中的文本显示为超链接。 html文件。我使用 R2HTML
包。
foo < - data。框架(a = c(1,2,3),b = c(4,5,6),
url = c('http://nytimes.com','http://cnn.com ','http://www.weather.gov'))
HTML(foo,file ='foo.html')
在上面的例子中,我想要 http://nytimes.com
等。在 foo.html
文件中显示为超链接。
如果我遗漏了一些明显的道歉,
解决方案
使用 googleVis
foo< - transform(foo,url = paste('< a href =',shQuote(url),'>',url,'< / a>'))
x = gvisTable(foo,options = list(allowHTML = TRUE))
plot(x)
While this question more generally has been looked at here:
I was wondering specifically how to have text in a data frame appear as a hyperlink in the .html file. I am using the R2HTML
package.
foo <- data.frame(a=c(1,2,3), b=c(4,5,6),
url=c('http://nytimes.com', 'http://cnn.com', 'http://www.weather.gov'))
HTML(foo, file='foo.html')
In the above example, I'd like the http://nytimes.com
, etc. to appear as hyperlinks in the foo.html
file.
Apologies if I am missing something obvious.
解决方案
Here is a solution using googleVis
foo <- transform(foo, url = paste('<a href = ', shQuote(url), '>', url, '</a>'))
x = gvisTable(foo, options = list(allowHTML = TRUE))
plot(x)
这篇关于使用超链接将R中的表导出为HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文