title: R: loop though multiple variables
body: <p>I have got Multiple data.frames (from the datasets package) loaded
  and I Use the svDialogs package for some simple data input</p>
  
  <p>require (svDialogs)</p>
  
  <p>a&lt;- iris<br>
  b&lt;- attitued</p>
  
  <pre><code>&gt; a
       Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
  1            5.1         3.5          1.4         0.2     setosa
  2            4.9         3.0          1.4         0.2     setosa
  3            4.7         3.2          1.3         0.2     setosa
  4            4.6         3.1          1.5         0.2     setosa
  5            5.0         3.6          1.4         0.2     setosa
  and so on
  </code></pre>
  
  <p><br></p>
  
  <pre><code>&gt; b
     rating complaints privileges learning raises critical advance
  1      43         51         30       39     61       92      45
  2      63         64         51       54     63       73      47
  3      71         70         68       69     76       86      48
  4      61         63         45       47     54       84      35
  5      81         78         56       66     71       83      47
  and so on
  </code></pre>
  
  <p>The loaded data frames are not always the same and derived from previous steps so their naming and number can change.</p>
  
  <p>What I want to do now is to loop though those data frames and ask how the column names should be renamed and each of the data
  frames should get a new variable new.names[FILENAME] in this case new.names.a and new.names.b so that in a later step those could 
  be assigned as the new column names for the specific data.frames.</p>
  
  <p>I think the first thing I need is to store the previously loaded dataframes in a variable</p>
  
  <pre><code>files&lt;- c("a", "b")
  </code></pre>
  
  <p>and apply something like this:</p>
  
  <pre><code>new.names &lt;- c()
  for (x in files)  
    for (m in names(a))
      new.names &lt;- c(new.names,dlgInput(sprintf('Enter new column name or press ok: "%s"', m), default=m, Sys.info()["n"])$res)
     for(i in files)
       assign(paste("new.names", i,sep=""), new.names)
  </code></pre>
  
  <p>Well it works for one data frame but not with multiple (it just repeats the column names of the same data frame as many times as there are values
  in the "files" variable). And it assigns the entered new column names to all new created variables (new.namesa, new.namesb). Actually, it should skip to the next variable (new.nameb) as soon as it starts to iterate the names of the second file ("b").</p>
  
  <p>The output if i don`t change the suggested original column names is:</p>
  
  <pre><code>&gt; new.namesa
   [1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"      "Sepal.Length"
   [7] "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"     
  &gt; new.namesb
   [1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"      "Sepal.Length"
   [7] "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species" 
  </code></pre>
  
  <p>So is there a possibility to solve this? I`m not to keen on using loops - i have read multiple times that those should be avoided in R.- if there is another solution (in the best of cases but not necessarily without the use of additional packages).</p>
  
  <p>Any Help would be appreciated since I`m really stuck at this point.</p>