title: Generate Data Frame from Count Data
body: <p>I am trying to create an unsummarized data frame from a data frame of count data.</p>
  
  <p>I have had some experience <a href="https://www.r-exercises.com/2016/10/07/creating-sample-datasets-exercises/" rel="nofollow noreferrer">creating sample datasets</a> but I am having some trouble trying to get a specific number of rows and proportion for each state/person without coding each of them separately and then combining them. I was able to do it using the following code but I feel like there is a better way.</p>
  
  <pre><code>set.seed(2312)
  dragon &lt;- sample(c(1),3,replace=TRUE)
  Maine  &lt;- sample(c("Maine"),3,replace=TRUE)
  Maine1 &lt;- data.frame(dragon, Maine)
  
  dragon &lt;- sample(c(0),20,replace=TRUE)
  Maine  &lt;- sample(c("Maine"),20,replace=TRUE)
  Maine2 &lt;- data.frame(dragon, Maine)
  
  Maine2
  
  library(dplyr)
  
  maine3 &lt;- bind_rows(Maine1, Maine2)
  </code></pre>
  
  <p><strong>Is there a better way to generate this dataset then the code above?</strong></p>
  
  <p>I am trying to create a data frame from the following count data:</p>
  
  <pre><code>+-------------+--------------+--------------+
  |             | # of dragons | # no dragons |
  +-------------+--------------+--------------+
  | Maine       |            3 |            20|
  | California  |            1 |            10|
  | Jocko       |           28 |       110515 |
  | Jessica Day |           17 |        26122 |
  |             |           14 |        19655 |
  +-------------+--------------+--------------+
  </code></pre>
  
  <p>And I would like it to look like this:</p>
  
  <pre><code>+-----------------------+---------------+
  |                       | Dragons (1/0) |
  +-----------------------+---------------+
  | Maine                 | 1             |
  | Maine                 | 1             |
  | Maine                 | 1             |
  | Maine                 | 0             |
  | Maine….(2:20)         | 0….           |
  | California            | 1             |
  | California….(2:10)    | 0…            |
  | Ect..                 |               |
  +-----------------------+---------------+
  </code></pre>
  
  <p>I do not want the code written for me but would love with ideas on function or examples that you think might be helpful.</p>