title: Calculate marginal probabilities from dataframe in R
body: <p>I would like to calculate the marginal probability distributions from a dataframe containing raw binary data. I'm sure there is an easy way, however I can not seem to find a function for it. Any ideas?
  I'm attaching a simple example of a dataframe of binary variables where an outcome can be considered as one and no outcome as 0.</p>
  
  <pre><code>set.seed(1234)
  respondent &lt;- 1:1000
  red &lt;- sample(0:1, 1000, replace=T)
  blue &lt;- sample(0:1, 1000, replace=T)
  green &lt;- sample(0:1, 1000, replace=T)
  black &lt;- sample(0:1, 1000, replace=T)
  grey &lt;- sample(0:1, 1000, replace=T)
  
  my.new.df &lt;- data.frame(respondent, red ,blue,green,black,grey)
  lapply(my.new.df[,2:6],sum)
  $red
  [1] 518
  
  $blue
  [1] 485
  
  $green
  [1] 515
  
  $black
  [1] 481
  
  $grey
  [1] 508
  </code></pre>