我有以下代码:
install.packages("XML")
library(XML)
feed <- "http://rss.cnn.com/rss/cnn_world.rss"
data1 <- xmlToDataFrame(xmlParse(feed)["/rss/channel/item"])
feed <- "http://www.usnews.com/rss/news"
data2 <- xmlToDataFrame(xmlParse(feed)["/rss/channel/item"])
bigdata <- merge(data1, data2, by = 'title', all = T)
print(bigdata)
我真的只对title
专栏感兴趣。如何从两个数据帧合并该列?
答案 0 :(得分:1)
如果你想得到所有新闻:
union(data1$title,data2$title)
另外,最好将stringsAsFactors
设置为FALSE以摆脱因素:
data1 <- xmlToDataFrame(xmlParse(feed)["/rss/channel/item"],
stringsAsFactors=FALSE)