是否可以从R中的Excel文件中提取超链接?我仔细查看过XLConnect,xlsx但我发现的唯一一件事就是如何编写超链接,而不是阅读它们.
更多信息:Excel文件包含其中一列中的超链接,这意味着您可以单击的文本将带您到文件或URL.当我使用打开文件XLConnect或xlsx我只看到(不再可点击)文本,但我需要URL.
我找到了一种超级复杂的方法来提取超链接:
library(XML)
# rename file to .zip
my.zip.file <- sub("xlsx", "zip", my.excel.file)
file.copy(from = my.excel.file, to = my.zip.file)
# unzip the file
unzip(my.zip.file)
# unzipping produces a bunch of files which we can read using the XML package
# assume sheet1 has our data
xml <- xmlParse("xl/worksheets/sheet1.xml")
# finally grab the hyperlinks
hyperlinks <- xpathApply(xml, "//x:hyperlink/@display", namespaces="x")
Run Code Online (Sandbox Code Playgroud)
源自此博客帖子.
| 归档时间: |
|
| 查看次数: |
1389 次 |
| 最近记录: |