title: assign rownames within a loop to constructed variables names
body: <p>I'm creating data frames within a loop. The data frames' name should be the combination of a name and a number (the loops iteration). I use the assign function for this and works. I also want to assign names to the data frames' rows. I tried two ways, but I'm getting the error messages "target of assignment expands to non-language object" and "only the first element is used as variable name". Below is a reproducible example of I'm trying to do.</p>
  
  <pre><code>rows&lt;-c("a","b")
  df&lt;-data.frame(var1=c(1,2),var2=c(10,20))
  for (n in 1:2){
    assign  (paste("data",n,sep="_"),df)
    rownames(get(paste("data",n,sep="_")))&lt;-rows        # it doesn't work
    assign(rownames(get(paste("data",n,sep="_"))),rows) # it doesn't work
  }
  </code></pre>
  
  <p>I'd like to know why it doesn't work and how to solve it. I found similar threads like <a href="https://stackoverflow.com/questions/9780025/target-of-assignment-expands-to-non-language-object-in-r2-14-2">this</a> and <a href="https://stackoverflow.com/questions/20549093/recode-and-target-of-assignment-expands-to-non-language-object">this</a>, but I was not able to solve my case. Thank you.</p>