title: Error in paste() <- function target of assignment expands to non-language object
body: <p>I have a data frame and would like to create sub data frames from each of those columns (except for the first one).
  But when trying to do this with a for loop, I get an error.</p>
  <p>Here's a toy data frame:</p>
  <pre><code>&gt; df &lt;- data.frame(my_names=sample(LETTERS,4,replace=F),
  +                  column2=sample(1.3:100.3,4,replace=T),
  +                  column3=sample(1.3:100.3,4,replace=T),
  +                  column4=sample(1.3:100.3,4,replace=T),
  +                  column5=sample(1.3:100.3,4,replace=T))
  &gt; df
    my_names column2 column3 column4 column5
  1        K     7.3    18.3    11.3    27.3
  2        N    17.3    56.3    92.3    82.3
  3        R    66.3     8.3    62.3    58.3
  4        Y    43.3    22.3    72.3    23.3
  &gt; 
  </code></pre>
  <p>What I want to get, for one of the columns, can be done like this:</p>
  <pre><code>&gt; top &lt;- 2
  &gt; top_column2 &lt;- df %&gt;% arrange(desc(column2)) %&gt;% select(my_names, column2) %&gt;% top_n(top, column2) %&gt;% mutate(column2=round(column2))
  &gt; top_column2
    my_names column2
  1        R      66
  2        Y      43
  &gt;
  </code></pre>
  <p>Now the code I tried to use:</p>
  <pre><code>&gt; for(i in 2:ncol(df)) {
  +   paste(&quot;top&quot;, colnames(df)[i], sep=&quot;_&quot;) &lt;- 
  +     df %&gt;% arrange(desc(i)) %&gt;% select(my_names, i) %&gt;% top_n(top, i) %&gt;% mutate(i=round(i))
  +   }
  Error in paste(&quot;top&quot;, colnames(df)[i], sep = &quot;_&quot;) &lt;- df %&gt;% arrange(desc(i)) %&gt;%  : 
    target of assignment expands to non-language object  
  </code></pre>
  <p>After googling, I tried also assign(paste(), function):</p>
  <pre><code>&gt; for(i in 2:ncol(df)) {
  +   assign(paste(&quot;top&quot;, colnames(df)[i], sep=&quot;_&quot;), 
  +     df %&gt;% arrange(desc(i)) %&gt;% select(my_names, i) %&gt;% top_n(top, i) %&gt;% mutate(i=round(i))) 
  + }
  &gt; top_column4
    my_names column4 i
  1        K    11.3 4
  2        N    92.3 4
  3        R    62.3 4
  4        Y    72.3 4
  </code></pre>
  <p>Four data frames were created with the right name but none of the functions were applied to the columns.</p>
  <p>Can anybody suggest how to deal with this?</p>