title: variable in the file name for write.table in R
body: <p>Please help me with naive question (already googled, and tried a lot of variations, but failed): How save files with the variable in the file name for write.table in R? Script loop over the files in dir, apply some functions and then save results into the file with the same name but additional ending. Thank's!</p>
  
  <pre><code>for (x in list.files(pattern="SIM")) {
                        u &lt;- read.table(x, header = T, row.names = 1, sep = " ")
                        ut &lt;- t(u)
                        utm &lt;- colMeans(ut)
                        utms &lt;- sort(utm, decreasing = T)
                        write.table(utms, "$x.mean")
                        }
  </code></pre>