title: Turn combinations of columns into some kind of interpretable variable
body: <p>I want to turn combinations of columns into some kind of interpretable variable. There are 3 levels of a factor repeated in three columns, for each id. For all the combinations between the variables I would like to gain a list, and when I have the lsit, I want to know how many times can we find each combination. For example, when q1 and q2 are the same, it should return &quot;A&quot;. An then A appear XX times. Anyone with suggestions? Thanks!!</p>
  <pre><code>id &lt;- 1:10
  set.seed(1)
  q1 &lt;- sample(1:3, 10, replace=TRUE) 
  set.seed(2)
  q2 &lt;- sample(1:3, 10, replace=TRUE) 
  set.seed(2)
  q3 &lt;- sample(1:3, 10, replace=TRUE) 
  
  df &lt;- data.frame(id,q1,q2,q3)
  df
  df
     id q1 q2 q3
  1   1  1  1  1
  2   2  2  3  3
  3   3  2  2  2
  4   4  3  1  1
  5   5  1  3  3
  6   6  3  3  3
  7   7  3  1  1
  8   8  2  3  3
  9   9  2  2  2
  10 10  1  2  2
  if df$q1==&quot;1&quot; &amp; df$q2==&quot;1&quot; print A
  if df$q1==&quot;1&quot; &amp; df$q2==&quot;2&quot; print B
  if df$q1==&quot;1&quot; &amp; df$q2==&quot;3&quot; print C
  if df$q1==&quot;2&quot; &amp; df$q2==&quot;3&quot; print D
  if df$q1==&quot;2&quot; &amp; df$q2==&quot;2&quot; print E
  if df$q1==&quot;3&quot; &amp; df$q2==&quot;3&quot; print F
  if df$q2==&quot;1&quot; &amp; df$q2==&quot;1&quot; print G
  if df$q2==&quot;1&quot; &amp; df$q2==&quot;2&quot; print H
  
  response &lt;- save(print A, print B, print C and so on....)
  length(A)
  length(B)
  and so on...
  </code></pre>