title: Plot the equivalent of correlation matrix for factors (categorical data)? And mixed types?
body: <p>Actually there are 2 questions, one is more advanced than the other.</p>
  
  <h1>Q1: I am looking for a method that similar to <a href="https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html" rel="noreferrer"><code>corrplot()</code></a> but can deal with factors.</h1>
  
  <p>I originally tried to use <code>chisq.test()</code> then calculate the <em>p-value</em> and <em>Cramer's V</em> as correlation, but there too many columns to figure out.
  So could anyone tell me if there is a quick way to create a "corrplot" that each cell contains the value of <em>Cramer's V</em>, while the colour is rendered by <em>p-value</em>.  Or any other kind of similar plot. </p>
  
  <p>Regarding <em>Cramer's V</em>, let's say <code>tbl</code> is a 2-dimensional factor data frame.</p>
  
  <pre><code>chi2 &lt;- chisq.test(tbl, correct=F)
  Cramer_V &lt;- sqrt(chi2$/nrow(tbl)) 
  </code></pre>
  
  <p>I prepared a test data frame with factors:</p>
  
  <pre><code>df &lt;- data.frame(
  group = c('A', 'A', 'A', 'A', 'A', 'B', 'C'),
  student = c('01', '01', '01', '02', '02', '01', '02'),
  exam_pass = c('Y', 'N', 'Y', 'N', 'Y', 'Y', 'N'),
  subject = c('Math', 'Science', 'Japanese', 'Math', 'Science', 'Japanese', 'Math')
  ) 
  </code></pre>
  
  <h1>Q2: Then I would like to compute a correlation/association matrix on a mixed-types dataframe e.g.:</h1>
  
  <pre><code>df &lt;- data.frame(
  group = c('A', 'A', 'A', 'A', 'A', 'B', 'C'),
  student = c('01', '01', '01', '02', '02', '01', '02'),
  exam_pass = c('Y', 'N', 'Y', 'N', 'Y', 'Y', 'N'),
  subject = c('Math', 'Science', 'Japanese', 'Math', 'Science', 'Japanese', 'Math')
  ) 
  df$group &lt;- factor(df$group, levels = c('A', 'B', 'C'), ordered = T)
  df$student &lt;- as.integer(df$student)
  </code></pre>