将超链接放入R中的HTML表 [英] Putting hyperlinks into an HTML table in R

查看:152
本文介绍了将超链接放入R中的HTML表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名研究计算机科学的生物学家,所以我可能有点天真。但我想创建一个包含数据框信息的表,其中一列包含超链接。我想这需要一个HTML文档(?)。我发现这篇文章这篇文章描述了如何设置超链接进入数据框并使用googleVis将其写为HTML文件。我想使用这种方法(它是我所知道的唯一一种似乎运行良好的方法),除了我想用描述替换实际的URL。真正的动机是我希望包含许多这些超链接,并且链接具有难以阅读的长地址。

I am a biologist trying to do computer science for research, so I may be a bit naïve. But I would like to a make a table containing information from a data frame, with a hyperlink in one of the columns. I imagine this needs to be an html document (?). I found this post this post describing how to put a hyperlink into a data frame and write it as an HTML file using googleVis. I would like to use this approach (it is the only one I know and seems to work well) except I would like to replace the actual URL with a description. The real motivation being that I would like to include many of these hyperlinks, and the links have long addresses which is difficult to read.

要详细,我基本上想要做我在这里做的事情,我们在这里读到'这里'但是'here'指向
http:// stackoverflow.com/questions/8030208/exporting-table-in-r-to-html-with-hyperlinks

To be verbose, I essentially want to do what I did here where we read 'here' but 'here' points to http:// stackoverflow.com/questions/8030208/exporting-table-in-r-to-html-with-hyperlinks

推荐答案

根据您之前的问题,您可以拥有另一个包含网址标题的列表:

From your previous question, you can have another list which contains the titles of the URL's:

url=c('http://nytimes.com', 'http://cnn.com', 'http://www.weather.gov'))
urlTitles=c('NY Times', 'CNN', 'Weather'))

foo <- transform(foo, url = paste('<a href = ', shQuote(url), '>', urlTitles, '</a>')) 
x = gvisTable(foo, options = list(allowHTML = TRUE))
plot(x)

这篇关于将超链接放入R中的HTML表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆