title: Extract multiple values from factor variable based on other factors in R
body: <p>Basically I would like to have new dataframe, coming from Extract multiple values from factor variable based on other factors in R, to be used later as ggplot's geom_text in facet_wrap labels.</p>
  
  <p>I tried and search and search, could not find what I need. I am sorry if turn out there is already this kind of question, and please show me the way to the link</p>
  
  <pre><code>year &lt;- c(2000,2000,2000,2001,2001,2002,2002,2002,2003,2004,2004,2004,2005,2005)
  skor &lt;- c("A","B","C","A","C","E","F","A","D","D","E","H","J","K")
  year &lt;- as.factor(year)
  data &lt;- data.frame(year,skor)
  
  &gt; data
     year skor
  1  2000    A
  2  2000    B
  3  2000    C
  4  2001    A
  5  2001    C
  6  2002    E
  7  2002    F
  8  2002    A
  9  2003    D
  10 2004    D
  11 2004    E
  12 2004    H
  13 2005    J
  14 2005    K
  </code></pre>
  
  <p>I would like to have new dataframe like this (or something similar), to be used later as ggplot's geom_text (<strong>skor</strong>) in facet_wrap (<strong>year</strong>)</p>
  
  <pre><code>year    skor
  2000    A,B,C
  2001    A,C
  2002    E,F,A
  2003    D
  2004    D,E,H
  2005    J,K
  </code></pre>
  
  <p>I tried and search and search, could not find what I need. I am sorry if turn out there is already this kind of question, and please show me the way to the link</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong> I've changed variable skor2 to skor, in the question, for other to be able to follow/reproduce. I used other name skor2 for ggplot later </p>