title: Naming elements in a list in r
body: <p>I have a list with 21 character strings called "r1score.list". I made this list by reading in text files from a folder. Then I made each txt into a data frame and put those in another list called "r1.score". (You can ignore the function(x){sortertoDF(x)} because I'm calling a function that I've written somewhere else to manipulate the data).</p>
  
  <pre><code>r1score.list &lt;- dir(pattern="*.txt")
  
  &gt; r1score.list
   [1] "p01_control.txt"   "p02_control.txt"   "p03_control.txt"   "p04_pq.txt"           "p05_pq.txt"        "p06_pq.txt"       
   [7] "p07_doce.txt"      "p08_doce.txt"      "p09_doce.txt"      "p10_dact.txt"      "p11_dact.txt"      "p12_dact.txt"     
  [13] "p16_carm.txt"      "p17_carm.txt"      "p18_carm.txt"      "p19_cisplatin.txt" "p20_cisplatin.txt" "p21_cisplatin.txt"
  [19] "p22_amsacrine.txt" "p23_amsacrine.txt" "p24_amsacrine.txt"
  
  r1.score &lt;- llply(.data=r1score.list, .fun=function(x){sortertoDF(x)})
  </code></pre>
  
  <p>Right now, I have named each data frame in r1.score by doing this:</p>
  
  <pre><code>names(r1.score) &lt;- r1score.list
  </code></pre>
  
  <p>But I want to name each data frame by just the word that comes after the underscore. Meaning, if I call the first data frame in r1.score, I want it to have the name "control". If I call the fourth data frame, I want it to have the name "pq". If I call the last data frame, I want it to have the name "amsacrine", etc etc. I don't want to go through 21 txt files and give them new names so that I could do this. Is there a simpler way??</p>
  
  <p>Thank you. </p>