简体   繁体   中英

Convert text in list to data frame

I have a list, and for example its second element is:

datf[2]
[[1]]
                              topicML                                gender
                                    "0"                                "male"
                             sentiment                               topicV 
                                   "0"                                    "0" 

I try to convert that second element of the list to a data frame wit the code a <- as.data.frame(datf[2]) , but it´s not working because the list is not in the proper way so that the code works.

So , as we see, each element of the list is a text and I want to convert it to a data frame with the following structure:

> s
  topicML gender sentiment topicV
1       0   male         0      0

How Can I do that?

您可以尝试以下方法:

do.call(rbind, datf)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM