R-使用unlist将输出转换为数据帧

R-使用unlist将输出转换为数据帧,r,rvest,R,Rvest,当我运行下面的代码时 library(rvest) elec<-read_html("https://en.wikipedia.org/wiki/Kenyan_general_election,_1988") res<-elec%>% html_nodes("table.wikitable")%>%html_table(fill=TRUE) res 我试图找出如何将其作为数据帧而不是列表中的数据帧(至少目前看来是这样)html\u表将节点或节点集(节点列表)作为输入。

当我运行下面的代码时

library(rvest)

elec<-read_html("https://en.wikipedia.org/wiki/Kenyan_general_election,_1988")
res<-elec%>% html_nodes("table.wikitable")%>%html_table(fill=TRUE)
res

我试图找出如何将其作为数据帧而不是列表中的数据帧(至少目前看来是这样)

html\u表
节点
节点集
(节点列表)作为输入。通过使用
html\u节点
提供长度为1的
节点集
,请改用
html\u节点

res<-elec%>% html_node("table.wikitable")%>%html_table(fill=TRUE)
res%html\u节点(“table.wikitable”)%%>%html\u表(fill=TRUE)

您可以将其指定为
df,也可以使用
html\u节点
(末尾不带“s”),因为在这种情况下,页面上只有一个
表。wikitable
res<-elec%>% html_node("table.wikitable")%>%html_table(fill=TRUE)