I have a list of lists, like this:
tweetsdata <- list(politician1=list(meanlikes=2, meanretweet=1), politician2=list(meanlikes=4, meanretweet=3))
My desidered output is a data frame tweetsdata_df
with 3 columns, like this:
| POLITICIAN | MEANLIKES | MEANRETWEETS |
| ----------- | --------- | ------------ |
| Politician1 | 2 | 1 |
| Politician2 | 4 | 3 |
If I do a simple as.data.frame(tweetsdata)
the output is a dataframe with 1 obs. of 4 variables (politician1.meanlikes, politician1.meanretweet, politician2.meanlikes, politician2.meanretweet)
If I try to create the dataframe manually I don't know how to access the right variable:
tweetsdata_df <- data.frame(POLITICIANS=names(tweetsdata), MEANLIKES=???, MEANRETWEETS=???)
What am I doing wrong?