title: Conditional Probability Tables in R
body: <p>I have this causal graph I want to create conditional probability tables for.</p>
  <p>How can I build out a conditional probability for the variable A, if it is dependent on D, G, and Q? i.e P(A|G,Q,D)
  Assuming G (Gender) is Male or Female, Qualified (Q) is Qualified or Unqualified, Department (D) is A,B,C, or D and Admit (A) is either Admitted or Rejected.</p>
  <p>I want to do this in R.
  For example the conditional probability table for D (which is dependent on G) would look like so (I'm just using arbitrary probabilities for now). How can I do this for the A variable when it's dependent on three variables?</p>
  <pre><code>A.lv &lt;- c(&quot;A&quot;, &quot;R&quot;)
  G.lv &lt;- c(&quot;M&quot;, &quot;F&quot;)
  Q.lv &lt;- c(&quot;Q&quot;,&quot;U&quot;)
  D.lv &lt;- c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;)
  
  D.prob &lt;- array(c(0.2,0.5,0.4,0.1,0.8,0.5,0.6,0.9),
                  dim = c(4,2),
                  dimnames = list(D = D.lv, G = G.lv))
  
     G
  D     M   F
    A 0.2 0.8
    B 0.5 0.5
    C 0.4 0.6
    D 0.1 0.9
  </code></pre>
  <p><a href="https://i.stack.imgur.com/lCGV8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lCGV8.png" alt="enter image description here" /></a></p>