title: Prompting user for multiple input files in R
body: <p>I'm trying to do something I think should be straight forward enough, but so far I've been unable to figure it out (not surprisingly I'm a noob)...</p>
  
  <p>I would like to be able to prompt a user for input file(s) in R. I've successfully used <code>file.choose()</code> to get a single file, but I would like to have the option of selecting more than one file at a time.</p>
  
  <p>I'm trying to write a program that sucks in daily data files, with the same header and appends them into one large monthly file. I can do it in the console by importing the files individually,  and then using <code>rbind(file1, file2,...)</code> but I need a script to automate the process. The number of files to append will not necessarily be constant between runs.</p>
  
  <p>Thanks</p>
  
  <p>Update: Here the code I came up that works for me, maybe it will be helpful to someone else as well</p>
  
  <pre><code>library (tcltk)
  File.names &lt;- tk_choose.files()   #Prompts user for files to be combined
  Num.Files &lt;-NROW(File.names)      # Gets number of files selected by user
  
  # Create one large file by combining all files
  Combined.file &lt;- read.delim(File.names [1], header=TRUE, skip=2) #read in first file of list selected by user
  for(i in 2:Num.Files){
                        temp &lt;- read.delim(File.names [i], header=TRUE, skip=2) #temporary file reads in next file
                        Combined.file &lt;-rbind(Combined.file, temp)              #appends Combined file with the last file read in
                        i&lt;-i+1
  }
  output.dir &lt;- dirname(File.names [1])  #Finds directory of the files that were selected
  
  setwd(output.dir)                      #Changes directory so output file is in same             directory as input files
  output &lt;-readline(prompt = "Output Filename: ")       #Prompts user for output file name
  outfile.name &lt;- paste(output, ".txt", sep="", collapse=NULL)
  write.table(Combined.file, file= outfile.name, sep= "\t", col.names = TRUE, row.names=FALSE)` #write tab delimited text file in same dir that original files are in
  </code></pre>