title: R - adding a count table in a dataframe
body: <p>I would like to get a count table from several values in my dataframe, which are spread over several columns.
  In my case, several of my subjects have one or more types of medication. Now they are mentioned in several columns. I would instead like to have each medication name in a separate column, and a 1 or 0 (a count) per subject if they have it or not. </p>
  
  <p>For example, my dataframe now looks like:</p>
  
  <pre><code>Pp  X           X2              X3              X4 
  1   NA          NA              NA              NA 
  2   trimipramin NA              NA              NA
  3   Quetiapin   venlafaxin      escitalopram    NA 
  4   duloxetin   amitriptylin    NA              NA
  5   quetiapin   citalopram      escitalopram    Lithium 
  6   NA          NA              NA              NA
  7   duloxetin   escitalopram    venlafaxin      NA
  </code></pre>
  
  <p>I would like to it look like:</p>
  
  <pre><code>Pp  trimipramin escitalopram    quetiapin   venlafaxin  duloxetin   …
  1   0           0               0           0           0           …
  2   1           0               0           0           0           …
  3   0           1               1           1           0           …
  4   0           0               0           0           1           …   
  5   0           1               1           0           0           …
  6   0           0               0           0           0           …
  7   0           1               0           1           1           …
  </code></pre>
  
  <p>Would it be possible to get such a count table added to my dataframe and not separately? 
  I assume dplyr's <code>spread()</code> might be useful in this case, but I couldn't get it to work :-(
  Any help?</p>