adding proportions table (and hopefully nothing else)
authoraaronshaw <aaron.d.shaw@gmail.com>
Wed, 28 Oct 2020 02:33:05 +0000 (21:33 -0500)
committeraaronshaw <aaron.d.shaw@gmail.com>
Wed, 28 Oct 2020 02:33:05 +0000 (21:33 -0500)
psets/pset5-worked_solution.html
psets/pset5-worked_solution.rmd

index 4378477ac428a7c0f27b4a8439071bda0a0ab8cd..4bb5504d688c3a948b06270c3f28f0e606ceeec1 100644 (file)
@@ -1617,6 +1617,12 @@ obama.tbl</code></pre>
 ## took_fruit FALSE TRUE
 ##      FALSE   593  322
 ##      TRUE    185  122</code></pre>
+<pre class="r"><code>obama.prop.tbl &lt;- proportions(table(took_fruit = df$fruit, saw_flotus = df$obama), margin = 2)
+obama.prop.tbl</code></pre>
+<pre><code>##           saw_flotus
+## took_fruit     FALSE      TRUE
+##      FALSE 0.7622108 0.7252252
+##      TRUE  0.2377892 0.2747748</code></pre>
 </div>
 <div id="pc4.-test-for-differences-between-groups" class="section level2">
 <h2>PC4. Test for differences between groups</h2>
@@ -1736,7 +1742,7 @@ p1</code></pre>
 <pre class="r"><code>library(xtable)
 print(xtable(obama.tbl), type = &quot;html&quot;)</code></pre>
 <pre><code>## &lt;!-- html table generated in R 4.0.3 by xtable 1.8-4 package --&gt;
-## &lt;!-- Mon Oct 26 11:16:05 2020 --&gt;
+## &lt;!-- Tue Oct 27 20:25:44 2020 --&gt;
 ## &lt;table border=1&gt;
 ## &lt;tr&gt; &lt;th&gt;  &lt;/th&gt; &lt;th&gt; FALSE &lt;/th&gt; &lt;th&gt; TRUE &lt;/th&gt;  &lt;/tr&gt;
 ##   &lt;tr&gt; &lt;td align=&quot;right&quot;&gt; FALSE &lt;/td&gt; &lt;td align=&quot;right&quot;&gt; 593 &lt;/td&gt; &lt;td align=&quot;right&quot;&gt; 322 &lt;/td&gt; &lt;/tr&gt;
index 32ced5cef1e6b686e9ca692755d36612a89b5bc4..f2c8991eef93fb3e3c087f42906b51388380b575 100644 (file)
@@ -70,6 +70,8 @@ summary(df)
 obama.tbl <- table(took_fruit=df$fruit, saw_flotus=df$obama)
 obama.tbl
 
+obama.prop.tbl <- proportions(table(took_fruit=df$fruit, saw_flotus=df$obama), margin=2)
+obama.prop.tbl
 ```
 
 ## PC4. Test for differences between groups

Community Data Science Collective || Want to submit a patch?