title: Add columns within a for loop R
body: <p>This is a part of a larger script- long story short, input to R is a semi-colon separated path to the location of my text files. All the text files are of the following format:</p>
  
  <p>File1:</p>
  
  <pre><code>Name1   3
  Name2   4
  Name3   55
  </code></pre>
  
  <p>File2:</p>
  
  <pre><code>Name1   4
  Name2   33
  Name3   102
  </code></pre>
  
  <p>File3:</p>
  
  <pre><code>Name1   12
  Name2   2
  Name5   33
  </code></pre>
  
  <p>Here is an example:</p>
  
  <pre><code>cond1&lt;-'/User/Desktop/File1;/User/Desktop/File2;/User/Desktop/File3'
  
  #separates the elements
  normalList&lt;-strsplit(cond1, ";")
  
  #now you can access each element 
  nor&lt;-unlist(normalList)
  
  baseNorm&lt;-vector("list", length(nor))
  dirNorm&lt;-vector("list", length(nor))
  pathNorm&lt;-vector("list", length(nor))
  Norm&lt;-vector("list", length(nor))
  new&lt;-vector("list", length(nor))
  for (i in 1:length(nor))
  {
    baseNorm[[i]] &lt;- basename(nor[i])
    dirNorm[[i]]&lt;-dirname(nor[i])
    pathNorm[[i]]&lt;-paste(dirNorm[[i]], baseNorm[[i]], sep="/")
    Norm[[i]]&lt;-read.delim(pathNorm[[i]], header=F)
  
  }
  </code></pre>
  
  <p>In the example here the input to R contains 3 files- however I need the script to be flexible enough that it can work for any number of files passed, hence the attempt with the for loop. The BIG IDEA is:
  1) Get the path to the specific file for all files.
  2) Load the text files into R
  3) Create a new file that contains the common first column (Name1, Name2, Name3). All the next columns in this new file correspond to the 2nd column of File1, File2, File3, File4, etc. 
  Essentially, I need to create a master file:</p>
  
  <pre><code>Name1   3   4   55
  Name2   4   33  102
  Name3   12  2   33
  </code></pre>
  
  <p>I am sure there is a much simpler solution even to the code I already have, since with all the [[]] I don't even know how to start writing a function that creates the master file. I just started using R, so any input is a valuable learning experience, and thank you in advance!  </p>