无法将WikipediaR包对象转换为数据帧

时间:2016-09-02 09:12:10

标签: r dataframe wikipedia-api

WikipediaR软件包提供了列出页面贡献者的强大功能。

包裹配置

install.packages("WikipediaR")
library (WikipediaR) 

收集贡献R'page

contribs_r_page <-  contribs(domain = "fr", page = "R")

问题:如何在data.frame中转换我的对象 contribs_r_page

str (contribs_r_page)

List of 4
 $ call        : language contribs(page = "R", domain = "fr")
 $ contribs    :'data.frame':   219 obs. of  3 variables:
 ..$ user     : Factor w/ 143 levels "0x010C","109.213.170.237",..: 87 73  121 9 121 64 11 81 47 121 ...
 ..$ userid   : Factor w/ 111 levels "0","1017","1019240",..: 97 86 28 1 28 50 1 44 7 28 ...
 ..$ timestamp: Factor w/ 219 levels "2004-02-09T19:44:05Z",..: 219 218 217 216 215 214 213 212 211 210 ...
   $ page        : Named chr [1:3] "0" "50889" "fr"
  ..- attr(*, "names")= chr [1:3] "ns" "_idx" ""
  $ testWikiPage:List of 4
 ..$ takeOnlyFirst: logi FALSE
 ..$ redirPage    : NULL
 ..$ test         : num 0
 ..$ warnMessage  : NULL
 - attr(*, "class")= chr "contribsClass"

我尝试了什么:

contribs_r_page_df <- as.data.frame.list (contribs_r_page)

1 个答案:

答案 0 :(得分:1)

从str输出我们可以看到contribs_r_page list对象包含一个名为contribs的data.frame,所以我们可以按如下方式访问它:

contribs_r_page$contribs