title: change .txt to .csv in R
body: <p>I have been able to create a code in R to batch formate all my .txt file to .csv files using</p>
  
  <pre><code>setwd("~/Desktop/test/")
  filelist = list.files(pattern = ".txt")
  for (i in 1:length(filelist)){
      input&lt;-filelist[i]
      output&lt;-paste0(input, ".csv")
      print(paste("Processing the file:", input))
      data = read.delim(input, header = TRUE)   
      setwd("~/Desktop/test/done/")
      write.table(data, file=output, sep=",", col.names=TRUE, row.names=FALSE)
      setwd("~/Desktop/test/")
  }
  </code></pre>
  
  <p>Works great but file still retains the .txt extension in the name
  Example origninal file = "sample1.txt" and then the new file says "sample1.txt.csv" The file works as a .csv but the extra ".txt" in the file name annoys me, anyone know how to remove it from name?
  thanks</p>