0

I scraped 99 user profiles from forums for my PhD research. The output is a list with 99 elements. Since each user can decide for himself which information he or she is going to put on the profile there's a different number of information snippets attached to each element. Here's a sample of the output (I also don't know why the numeration has all these $ and ' signs) :

$`77.1`
$`77.1`[[1]]
[1] "Username:"

$`77.1`[[2]]
[1] "*Username*"

$`77.1`[[3]]
[1] "*Username*"

$`77.1`[[4]]
[1] "Rank:"

$`77.1`[[5]]
[1] "*Rank*"

$`77.1`[[6]]
[1] "Groups:"

$`77.1`[[7]]
[1] "*Groups*"

$`77.1`[[8]]
[1] "Location:"

$`77.1`[[9]]
[1] "*Location*"

$`77.1`[[10]]
[1] ""



$`78.1`
$`78.1`[[1]]
[1] "Username:"

$`78.1`[[2]]
[1] "*Username*"

$`78.1`[[3]]
[1] "*Username*"

$`78.1`[[4]]
[1] "Rank:"

$`78.1`[[5]]
[1] "*Rank*"

$`78.1`[[6]]
[1] "Age:"

$`78.1`[[7]]
[1] "*AGE*"

$`78.1`[[8]]
[1] "Groups:"

$`78.1`[[9]]
[1] "*Groups*"

$`78.1`[[10]]
[1]"Interests in history:"

$`78.1`[[11]]
[1] "*Interests*"

$`78.1`[[12]]
[1] "Location:"

$`78.1`[[13]]
[1] "*Location*"

$`78.1`[[14]]
[1] ""

Is there a way to arrange this list into a data frame where each row consists of information from one element?

I tried to arrange them into a matrix, but this doesn't work well because the matrix needs a consistent amount of columns, which isn't given.

I would love it to look like this:

Id      1              2         3        4           5          6
1     Username:    *Username*    Rank    *Rank*     Groups:   *Groups* 
2     Username:    *Username2* ... 
David Arenburg
  • 91,361
  • 17
  • 137
  • 196
  • 2
    try `plyr::rbind.fill`. Alternatively, paste in a `dput(head(data))`. The `$` and ` are the way r handles lists. – jeremycg Oct 07 '15 at 15:31
  • Thanks! `Rbind.fill` seems just like the right thing to do, but somehow after I apply it to the data frame that was created from the output list, and write it into an .xlsx-file, it just lists all of the elements again. Moreover, it seems to me that `dput()` only puts files into .txt files. Is that right? – Anastasia Pupynina Oct 09 '15 at 09:13
  • The `dput` would be to paste into the question above, for a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Otherwise it's hard to say exactly how to fix your problem. – jeremycg Oct 09 '15 at 12:44

0 Answers0