title: Testing difference between proportions in R
body: <p>I am a bit confused with conducting a test of proportions in R. Maybe this is super obvious, but <code>prop.test</code> behaves differently than I expected, and I would like to know why and what to use instead. The application is on a dataset of protest events.</p>
  <p>I constructed the following dataset:</p>
  <p><a href="https://i.stack.imgur.com/kYxOy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kYxOy.png" alt="enter image description here" /></a></p>
  <p>where the name refers to the <em>type</em> of the percentage of events being calculated. The first row refers to events organized after elections (aft_elect_prt). Within each of this category I calculate the number of events which have (past_pm1)  or have not been linked to a group of a former prime minister (past_pm0) . Total refers to the number of events in the dataset of the specific type. Share0 is past_pm0/total, share1 is past_pm1/total.</p>
  <p>I want to test the null hypothesis that there is no statistically significant difference between the two shares.</p>
  <p>Reading the documentation of <code>prop.test</code> I set it up as:</p>
  <pre><code>prop.test(x = as.numeric(subseted$past_pm1),
            n = subseted$total,
            p = subseted$share0,
            alternative = &quot;two.sided&quot;,
            conf.level = 0.95)
  </code></pre>
  <p>However, this obviously does not test what I want. It also results in only one p value, whereas I would like to extract a p value for each row. What function/test should I use instead?</p>
  <p>This is the dput code for the dataset:</p>
  <pre><code>structure(list(names = c(&quot;aft_elect_prt&quot;, &quot;ANSM&quot;, &quot;bef_elect_prt&quot;, 
  &quot;big_event&quot;, &quot;conf_viol&quot;, &quot;coorg&quot;, &quot;demo_petition&quot;, &quot;economic&quot;, 
  &quot;NSM&quot;, &quot;political&quot;), past_pm0 = c(49.66101, 78.54659, 65.57226, 
  49.67205, 39.641924, 69.52704, 286.8565, 68.53114, 100.00488, 
  117.97347), past_pm1 = c(33.796, 14.30855, 34.40608, 31.14065, 
  9.017051, 30.64896, 120.4515, 20.86095, 19.00836, 71.24065), 
      total = c(83.4570157825947, 92.8551414906979, 99.9783371835947, 
      80.8127028793097, 48.6589741557837, 100.176002234221, 407.307988807559, 
      89.3920872062445, 119.013234868646, 189.21411934495), share0 = c(0.595048954654295, 
      0.8459045857775, 0.655864678761227, 0.614656461548911, 0.814688856223823, 
      0.69404885850245, 0.704274180429913, 0.766635416419863, 0.84028368870382, 
      0.623491895892433), share1 = c(0.404950976057405, 0.154095398168484, 
      0.344135349408928, 0.385343502821669, 0.185311161125829, 
      0.305951119194593, 0.295725847049147, 0.233364614832964, 
      0.159716354412006, 0.376508107569518)), row.names = c(NA, 
  -10L), class = &quot;data.frame&quot;)
  </code></pre>