如何从Excel中提取URL并使用R将其与显示的文本匹配?

如何从Excel中提取URL并使用R将其与显示的文本匹配?,r,excel,xml,R,Excel,Xml,我有一个包含大量超链接的Excel文件,我想编写一个程序来提取URL并将其与显示的文本相匹配。我可以将带有解决方案的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 f

我有一个包含大量超链接的Excel文件,我想编写一个程序来提取URL并将其与显示的文本相匹配。我可以将带有解决方案的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")
库(XML)
#将文件重命名为.zip
my.zip.file