gpt4 book ai didi

html - 使用超链接将 R 中的表格导出到 HTML

转载 作者:搜寻专家 更新时间:2023-10-31 22:22:49 24 4
gpt4 key购买 nike

虽然这个问题已经在这里得到了更广泛的研究:

Exporting R tables to HTML

我特别想知道如何让数据框中的文本在 .html 文件中显示为超链接。我正在使用 R2HTML 包。

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')

在上面的示例中,我希望 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)

关于html - 使用超链接将 R 中的表格导出到 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8030208/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com