title: Error in assign - invalid first argument
body: <p>I am trying to create a new data frame column and assign values to it within a for-loop. </p>
  
  <p>Specifically, I have a list of data frame names and I am looping over this list one by one. For each name I want to create a column <code>$location</code> for that data frame and I want to assign it a value.  For simplicity sake, let's say I want to assign it <code>NA</code>.  The code below explains what I'm trying to do.  However, when I run it, I receive the error <code>Error in assign(get(name)$location, NA) : invalid first argument</code></p>
  
  <pre><code>names&lt;-c("europe", "africa", "asia")
  # where each of the strings in `names` is the name of an existing data frame object
  # for sake of example, code is provided below to create example data frame objects
  
  x &lt;- c(2,6,7)
  y &lt;- c(40, 42, 14)
  europe &lt;- data.frame(x,y)
  africa &lt;- data.frame(x,y)
  asia &lt;- data.frame(x,y)
  
  for (name in names) {
    assign(get(name)$location, NA)
  }
  </code></pre>
  
  <p>My goal is to get a new column called location in each of my data frames. I have no idea how to correct this or why it is happening. Any help would be greatly appreciated.</p>