title: R: can chisq.test() take a table as an object?
body: <p>The R-documentation at <code>?chisq.test()</code> says that x has to be </p>
  
  <blockquote>
    <p>a numeric vector or matrix. x and y can also both be factors</p>
  </blockquote>
  
  <p>Yet on the internet you find examples of <code>chisq.test</code> being run on contingency tables, i.e. creating a table from a dataframe using </p>
  
  <pre><code>mytable &lt;- table(df$a, df$b)
  </code></pre>
  
  <p>and then running <code>chisq.test</code> on </p>
  
  <pre><code>chisq.test(mytable)
  </code></pre>
  
  <p>Are the chi-square values and p values obtained this way valid?</p>