title: tidyverse - prefered way to turn a named vector into a data.frame/tibble
body: <p>Using the <code>tidyverse</code> a lot i often face the challenge of turning named vectors into a <code>data.frame</code>/<code>tibble</code> with the columns being the names of the vector.<br>
  <strong>What is the prefered/tidyversey way of doing this?</strong><br>
  EDIT: This is related to: <a href="https://github.com/hadley/dplyr/issues/1676" rel="noreferrer">this</a> and <a href="https://github.com/hadley/purrr/issues/255" rel="noreferrer">this</a> github-issue</p>
  
  <p>So i want:</p>
  
  <pre><code>require(tidyverse)
  vec &lt;- c("a" = 1, "b" = 2)
  </code></pre>
  
  <p>to become this:</p>
  
  <pre><code># A tibble: 1 × 2
        a     b
    &lt;dbl&gt; &lt;dbl&gt;
  1     1     2
  </code></pre>
  
  <p>I can do this via e.g.:</p>
  
  <pre><code>vec %&gt;% enframe %&gt;% spread(name, value)
  vec %&gt;% t %&gt;% as_tibble
  </code></pre>
  
  <p>Usecase example:</p>
  
  <pre><code>require(tidyverse)
  require(rvest)
  txt &lt;- c('&lt;node a="1" b="2"&gt;&lt;/node&gt;',
           '&lt;node a="1" c="3"&gt;&lt;/node&gt;')
  
  txt %&gt;% map(read_xml) %&gt;% map(xml_attrs) %&gt;% map_df(~t(.) %&gt;% as_tibble)
  </code></pre>
  
  <p>Which gives</p>
  
  <pre><code># A tibble: 2 × 3
        a     b     c
    &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
  1     1     2  &lt;NA&gt;
  2     1  &lt;NA&gt;     3
  </code></pre>