Quantcast
Viewing all articles
Browse latest Browse all 206594

Trouble converting list to dataframe

I have a list that's called my_list and looks like this:

$love 
playing working sleeping 
   0.43    0.56     0.88
$will 
otherwise rework rule 
    0.87    0.23  0.11
$new
car  shirt
0.23   0.12

I want to convert it to the following dataframe, with the output looking like this:

Column 1 Column 2 Column 3 
love     playing     0.43
love     working     0.56
love     sleeping    0.88
will     otherwise   0.87
will     rework      0.23
will     rule        0.11
new      car         0.23
new      shirt       0.12

I have tried this

  df <- do.call(rbind,lapply(cor1,as.data.frame))

but then the columns become the default columns of the dataframe:

love.playing 0.43 
love.working .56

and so on (basically i have only one column with the numbers). Any help will be much appreciated.


Viewing all articles
Browse latest Browse all 206594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>