title: Trying to generate a table with prevalence/10,000 with 95% Wilson confidence interval by categorical variable
body: <p>All the variables other than &quot;termx&quot; are &quot;0&quot;, &quot;1&quot;. &quot;1&quot; represents &quot;Yes&quot; or &quot;Exposed&quot;
  I would want to generate a table with prevalence /10,000 (Wilson's 95% CI) by the variable &quot;termx&quot;</p>
  <pre><code>str(b.pcalc)
  tibble [141,648 x 5] (S3: tbl_df/tbl/data.frame)
  $ pcalc_anenc  : Factor w/ 2 levels &quot;0&quot;,&quot;1&quot;: 1 1 1 1 1 1 1 1 1 1 ...
  $ pcalc_ence   : Factor w/ 2 levels &quot;0&quot;,&quot;1&quot;: 1 1 1 1 1 1 1 1 1 1 ...
  $ pcalc_spin   : Factor w/ 2 levels &quot;0&quot;,&quot;1&quot;: 1 1 1 1 1 1 1 1 1 1 ...
  $ pcalc_micr   : Factor w/ 2 levels &quot;0&quot;,&quot;1&quot;: 1 1 1 1 1 1 1 1 1 1 ...
  $ termx        : Factor w/ 7 levels &quot;39-40 weeks&quot;,..: 5 5 1 5 4 5 5 5 5 5 ...
  ..- attr(*, &quot;label&quot;)= chr &quot;Pregnancy Terms&quot;
  </code></pre>
  <p>I would like the table to look like this:</p>
  <pre><code>| Birth defects |   &lt;28 weeks | 28 to &lt;32 weeks | 32 to &lt;37 weeks | 37-38 weeks | 39-40 weeks | 41-&lt;42 weeks | 42+ weeks | 
  | ------------- |   --------- | --------------- | --------------- | ----------- | ----------- | ------------ | --------- |
  | pcalc_anenc | 15.5 (2.7,87.0) | 19.7 (7.7,50.6) | 3.2 (1.4,7.5) | 0.2 (0.0,1.1) | 0.2 (0.0,1.1) | 0.0 (0.0,3.0) | 2.7 (0.7,10.0) | 
  | pcalc_ence | 0.0 (0.0,59.0) | 4.9 (0.9,27.9) | 2.6 (1.0,6.6) | 1.7 (0.9,3.2) | 0.2 (0.0,1.1) | 0.0 (0.0,3.0) | 0.0 (0.0,5.2) | 
  | pcalc_spin | 15.5 (2.7,87.0) | 4.9 (0.9,27.9) | 9.0 (5.4,15.1) | 4.9 (3.4,7.2) | 3.2 (1.9,5.1) | 1.6 (0.4,5.8) | 2.7 (0.7,10.0) | 
  </code></pre>